-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Popover: Add virtual padding to prevent it from hitting the viewport edge #69555
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: Add virtual padding to prevent it from hitting the viewport edge #69555
Conversation
overflowOffset
prop to control maximum height calculationoverflowOffset
prop to support adding an offset between popover and viewport edge
overflowOffset
prop to support adding an offset between popover and viewport edgeoverflowOffset
prop to support adding an offset
b6f0322
to
15888d8
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
Does this problem not affect the X axis? The current prop naming and descriptions feel a bit misleading on first glance because it only works on the Y axis.
I'm also wondering if these "padding" values (as Ariakit names it) should actually be set globally in some way, at least at the app level, if not at the wp-components level. I haven't assessed all the use cases, but it seems like this padded behavior is something all popovers would want by default?
overflowOffset
prop to support adding an offsetoverflowOffsetY
prop to support adding an offset
06d0b01
to
18f4007
Compare
I couldn’t find any instances where the popover overflows to the viewport edge along the X-axis. This is likely because, in most cases, the popover does not extend beyond the associated toggle button in that direction.
Additionally, popovers rarely become scrollable along the X-axis, and when they do, it may not provide the best user experience. I'm interested in also knowing your thoughts on this.
I've fixed this in 18f4007
Since most popovers don’t extend to the viewport edge due to their typically limited content, it might be best to handle these scenarios on a case-by-case basis. That said, applying a global padding style or setting the default |
Some quick thoughts:
|
overflowOffsetY
prop to support adding an offsetoverflowPadding
prop to support adding an offset
fc04545
to
784fb4d
Compare
784fb4d
to
0cd2051
Compare
0cd2051
to
efe6ec6
Compare
packages/nux/src/components/dot-tip/test/__snapshots__/index.js.snap
Outdated
Show resolved
Hide resolved
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.
The overall approach LGTM, I'll leave it up to the rest of the folks for final reviews and merging :)
d1c2b6f
to
17f69c8
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.
This PR works well for me.
@yogeshbhutkar Finally, can you just resolve the conflict?
6637dfb
to
db5b287
Compare
overflowPadding
prop to support adding an offset…edge (WordPress#69555) * feat: introduce `overflowOffset` prop to control maximum height calculation * fix: set default value for `overflowOffset` prop in Popover component * chore: add changelog entry * fix: rename `overflowOffset` prop to `overflowOffsetY` for clarity * chore: update changelog to include `overflowOffsetY` prop for Popover component * fix: use `padding` instead of manual offset implementation * fix: add a static `8px` overflow padding * chore: move CHANGELOG * chore: update unit test snapshots * revert: restore changes made to snapshot file * fix: update maxHeight, maxWidth to accomodate overflowPadding * fix: remove maxWidth calculations * fix: use `padding` within `size` middleware * chore: move `CHANGELOG` to `Unreleased` section Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: stokesman <presstoke@git.wordpress.org> Co-authored-by: okmttdhr <okat@git.wordpress.org>
What?
Closes #69553
This PR introduces a new
overflowPadding
prop for thePopover
component, allowing precise control over the offset between the popover container and the viewport edge.Why?
Previously, there was no way to adjust the offset when the popover container reached the viewport edge, often cutting it off or partially obscuring near screen boundaries.
How?
overflowPadding
was introduced.padding
property withinsize
middleware fromfloating-ui
.Testing Instructions
View Options
.Browser Window
.Testing Instructions for Keyboard
Same.
Screenshots
Before
After