-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: smoothly reposition on scroll #18813
Conversation
Are you sure you couldn't just use
|
@ZebulanStanphill How would you use that for a |
@ellatrix Good point. I didn't think that through enough. |
The animation when opening the block More options or the More tools & options popovers is gone. |
@ZebulanStanphill I don’t see the animation in master either. |
@ellatrix I didn't test this branch but in master I do see the animation (make sure you're not in prefers reduced mode and the "disable animation" plugin should be disabled) |
@youknowriad Ah, for some reason I had only that test plugin enabled... Strange :) |
@ZebulanStanphill For me the animation works with this branch as well, if you make sure the "disable animation" plugin is disabled. |
I just checked, and yep, the "Gutenberg Test Plugin, Disables the CSS animations" was enabled. I never enabled it. Is it supposed to be enabled by default when you create a dev environment? (I'm using the Anyway, it looks like there are no issues (that I know of) on this branch after all. |
@ZebulanStanphill I have the same issue. The plugin always gets activated for some reason, I suspect by e2e tests? Thank you for testing the PR! |
f3f79b4
to
9733838
Compare
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.
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.
@gziolo mentioned https://popper.js.org/ as a great popover lib. I wonder if we could make our Popover component just a wrapper around and avoid the maintainability costs. (It's a separate topic from this PR though)
@youknowriad I'd love us to have more use cases in Gutenberg for |
@youknowriad I cannot scroll the document sidebar on mobile in |
This is fixed too. |
This is working well for me. I was hoping it would fix the issue where sometimes the scrollbar in popovers don't appear (you can trigger it inconsistently in the More menu or the block settings menu) but unfortunately, it doesn't, it still happens sometimes. I was curious whether you have an idea why this happens sometimes. |
I see what you mean. Looks like a bug somewhere else in the code, but I'll have a look. |
so basically, it scales down, but doesn't scale up again. |
@youknowriad I think I fixed both those issues now. |
@youknowriad Thanks for catching that. It should be fixed now. The problem was that I didn't unset the max height if none was provided (and kept the old one instead). |
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.
LGTM 👍
There are some Github issues that will be fixed with this (the scrollbar issues)
Many thanks for the review, @youknowriad! |
Description
Fixes #16643.
Blocks #18779.
This PR refactors the
Popover
component so that it smoothly repositions on scroll. Currently we do have logic to reposition it for every scroll frame, but thePopover
is always rerendered too late (and thus the style attributes reset too late). Why is that? Because currently we set it with React state, which then rerenders the component. Since this is not done synchronously, there's a small delay.The only way we can fix this is by avoiding setting state. Instead, we should update the DOM immediately. This is also more performant. There's no way around the DOM, unfortunately.
As a result, I think the component has also become simpler. There's no need for the many nested hooks and passing around props. I also swapped out the
is-*
classes in favour ofdata-
attributes, which are much easier to update.How has this been tested?
Open some popovers and play with scrolling and resizing. Nothing else should be different from
master
.Screenshots
Types of changes
Bug fix
Checklist: