Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SceneGridLayout: Prevent panels from moving on mount #733

Merged
merged 2 commits into from
May 10, 2024

Conversation

torkelo
Copy link
Member

@torkelo torkelo commented May 10, 2024

Noticed panels moving about when coming back to dashboard from dashboard settings and sometimes from panel edit.

This fixes that problem, I am using a ref here and updating the class using dom classList to avoid having to always re-render the full grid after mount

@torkelo torkelo added the minor Increment the minor version when merged label May 10, 2024
@@ -138,6 +147,18 @@ function validateChildrenSize(children: SceneGridItemLike[]) {
}
}

function updateAnimationClass(ref: React.MutableRefObject<HTMLDivElement>, isDraggable: boolean, retry?: boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works! Question out of curiosity. Could just use the dependencies array from useEffect to rerun the class adjustment when the ref or ref.current changes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ivanortegaalba useEffects are not triggerred when a useRef changes, for that we would have to store the ref in a useState (which would re-render the whole grid and loose the point of using the ref to set class)

Initializing to null the ref to be compatible with LegacyRef
Copy link
Contributor

@ivanortegaalba ivanortegaalba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@torkelo I pushed a small commit to fix the types errors, caused by a known React type issue. I hope you don't mind 😄

@torkelo torkelo merged commit 5ed9947 into main May 10, 2024
3 checks passed
@torkelo torkelo deleted the prevent-animation-always branch May 10, 2024 12:32
@grafanabot
Copy link
Contributor

🚀 PR was released in v4.20.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged released
Projects
Status: 🚀 Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants