From 3a76892df82c2fd5abb4651fab26fe894cece98e Mon Sep 17 00:00:00 2001 From: Rares Mardare Date: Mon, 4 Mar 2024 13:43:09 +0200 Subject: [PATCH] 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. --- CHANGELOG.md | 1 + .../src/containers/RotationForm/RotationForm.tsx | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88b44a4b..d513365a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/grafana-plugin/src/containers/RotationForm/RotationForm.tsx b/grafana-plugin/src/containers/RotationForm/RotationForm.tsx index d5cd251e..de21b9f8 100644 --- a/grafana-plugin/src/containers/RotationForm/RotationForm.tsx +++ b/grafana-plugin/src/containers/RotationForm/RotationForm.tsx @@ -716,10 +716,11 @@ export const RotationForm = observer((props: RotationFormProps) => { return; } + const scrollBarReferenceElements = document.querySelectorAll('.scrollbar-view'); // top navbar display has 2 scrollbar-view elements (navbar & content) - const baseReferenceEl = document.querySelectorAll('.scrollbar-view')[1]; - - const baseReferenceElRect = baseReferenceEl.getBoundingClientRect(); + const baseReferenceElRect = ( + scrollBarReferenceElements.length === 1 ? scrollBarReferenceElements[0] : scrollBarReferenceElements[1] + ).getBoundingClientRect(); const { right, bottom } = baseReferenceElRect;