Check if base element exists when dragging the rotation form (#3986)

# What this PR does

Right now depending on whether the left bar is pinned or not, the
existing base element (this is to determine the dragging margins) query
might fail if it cannot find the expected element. Added a check to see
whether it exists or not.
This commit is contained in:
Rares Mardare 2024-03-04 13:43:09 +02:00 committed by GitHub
parent 20973705e9
commit 3a76892df8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fix template preview by @vadimkerr ([#3937](https://github.com/grafana/oncall/pull/3937))
- Fix an issue when dragging the rotation form ([#3986](https://github.com/grafana/oncall/pull/3986))
## v1.3.106 (2024-02-20)

View file

@ -716,10 +716,11 @@ export const RotationForm = observer((props: RotationFormProps) => {
return;
}
const scrollBarReferenceElements = document.querySelectorAll<HTMLElement>('.scrollbar-view');
// top navbar display has 2 scrollbar-view elements (navbar & content)
const baseReferenceEl = document.querySelectorAll<HTMLElement>('.scrollbar-view')[1];
const baseReferenceElRect = baseReferenceEl.getBoundingClientRect();
const baseReferenceElRect = (
scrollBarReferenceElements.length === 1 ? scrollBarReferenceElements[0] : scrollBarReferenceElements[1]
).getBoundingClientRect();
const { right, bottom } = baseReferenceElRect;