-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix moving block popover when zoomed out #65981
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -69,8 +69,16 @@ function BlockPopover( | |||||||||||||||||||||||
); | ||||||||||||||||||||||||
observer.observe( selectedElement, { attributes: true } ); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
const zoomedOutObserver = new window.MutationObserver( | ||||||||||||||||||||||||
forceRecomputePopoverDimensions | ||||||||||||||||||||||||
); | ||||||||||||||||||||||||
zoomedOutObserver.observe( selectedElement.closest( 'html' ), { | ||||||||||||||||||||||||
attributes: true, | ||||||||||||||||||||||||
} ); | ||||||||||||||||||||||||
Comment on lines
+75
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're really eager with these comments lately. In this case the new code is next to the old code doing the same thing. If the old code was understandable I think the new one is too. The name of the variable is also an indicator of why the observer is there 🤷🏻 |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
return () => { | ||||||||||||||||||||||||
observer.disconnect(); | ||||||||||||||||||||||||
zoomedOutObserver.disconnect(); | ||||||||||||||||||||||||
}; | ||||||||||||||||||||||||
}, [ selectedElement ] ); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be a bit too aggressive to recompute the popover position on every attribute change. In addition, I don't think it's immediately clear why we want to observe only the
html
element for the zoom out mode. Another idea would be usingResizeObserver
in a similar way, which I believe we already have one somewhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting that we are observing the
html
element only. This is because the default for thesubtree
option of the.observe()
method isfalse
.Therefore this should only be recomputing if attributes change on the
html
node itself. How often does that realistically happen? Probably quite infrequently.I could be wrong but it's worth noting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I mentioned this above:
A comment above would be nice so people won't accidentally break it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. I misinterpreted your comment. Comment always good