-
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
Popover: fix inserter glitch #18955
Popover: fix inserter glitch #18955
Conversation
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.
As a result, if you open the sibling inserter, the content height will continuously change, causing the content to move up and down every half second.
I can't seem to reproduce this. Is this browser specific?
@epiqueras No, I think it's for all browsers. It just got reported here: #18953. |
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.
This fixes that particular issue but there's still other glitches, for example, if you open the "More Menu" (top right) in a screen with a small height and then scroll to the bottom of the menu, you'll notice that it will jump to the top again.
@youknowriad Ah, I see what you mean. It looks like we cannot measure the height after the first time, then, so I'll revert it back to the old behaviour of only measuring once at the start. This will introduce the problem with the "Block Settings" ellipsis menu again though. We have to figure out why the height is not measured correctly at the start. |
yeah, hard problem. Maybe the content is not ready on first render for some reason for these popovers. |
@youknowriad It should be fixed now. Looks like at the animation frame the height is good for both popovers. |
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.
This is magic
Ugh, this makes a number of jest tests fail that rely on having the popover visible immediately. |
I'm not sure what to do about the tests here. For the tests, a later refresh fails them. I don't have a good understanding of the react DOM test utils and I'm not sure what they fail... |
Maybe @gziolo can help here :) |
The refresh on animation frame is somehow confusing the tests. If I use |
@ellatrix there's some tricks here jestjs/jest#5147 |
c4f047b
to
52e73b9
Compare
It looks like a timeout (0) works just fine as well and leaves the tests working. Let's go for that then. I suspect the underlying height problem is the same as: gutenberg/packages/components/src/popover/index.js Lines 134 to 140 in c75761c
Hopefully we find can figure out a proper solution in a follow up PR. Cc @aduth since you created #11430. |
Nice work! Interestingly, I was never able to replicate #18953 on my machine. |
@epiqueras I did reproduce before this PR, i think it was related to viewport size somehow. |
Ah, that could be it! |
Description
Fixes #18953.
Since #18813, the popover content height it calculated with
scrollHeight
, but this doesn't work properly if the content itself contains another scroll container. As a result, if you open the sibling inserter, the content height will continuously change, causing the content to move up and down every half second.The solution is to revert to using
getBoundingClientRect
withoutmaxHeight
set. This can be done right at the start, and for performance reasons at every interval after that because we have to removemaxHeight
first to get the bounding client rect.How has this been tested?
Screenshots
Types of changes
Checklist: