-
Notifications
You must be signed in to change notification settings - Fork 1.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
[PositionedOverlay] Add support for horizontal positioning #11443
Conversation
70ad850
to
e223144
Compare
211d227
to
507a80f
Compare
left: left == null || isNaN(left) ? undefined : left, | ||
right: right == null || isNaN(right) ? undefined : right, | ||
width: width == null || isNaN(width) ? undefined : width, | ||
'--pc-positioned-overlay-top': nextTop, |
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.
Though these could all technically move to CSS variables set and updated in the CSS, these properties still need to be set on the style property otherwise there is cascade collision with children.
this.setState( | ||
{ | ||
measuring: false, | ||
activatorRect: getRectForNode(activator), | ||
activatorRect, |
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 was already defined as a variable on line 265 (line 274 now), so removed the redundancy.
507a80f
to
09cc676
Compare
const verticalMargins = overlayMargins.activator + overlayMargins.container; | ||
const minimumSpaceToScroll = overlayMargins.container; | ||
const distanceToTopScroll = |
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 math was causing the available vertical space to be undercalculated, causing the overlay to switch positions sooner than necessary. I fixed this and made the variable names clearer so it's easier to understand what's going on here.
…sition not working; fix available width not accounting for child min-width
5e194a0
to
d7a7c3d
Compare
:root { | ||
// stylelint-disable polaris/conventions/polaris/custom-property-allowed-list -- PositionedOverlay CSS Properties; Supports consuming component styles tying into changes in order to animate without hacky JavaScript timers and forcing reflow | ||
--pc-positioned-overlay-top: initial; | ||
--pc-positioned-overlay-bottom: initial; | ||
// stylelint-enable | ||
} | ||
|
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.
CSS Custom Properties have a default value of initial
when not set, so defining these on :root
is the same as not defining them at all.
:root { | |
// stylelint-disable polaris/conventions/polaris/custom-property-allowed-list -- PositionedOverlay CSS Properties; Supports consuming component styles tying into changes in order to animate without hacky JavaScript timers and forcing reflow | |
--pc-positioned-overlay-top: initial; | |
--pc-positioned-overlay-bottom: initial; | |
// stylelint-enable | |
} |
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.
Thanks Jess! They're initialized so they can be updated in the PositionedOverlay.tsx. So are you saying they don't need to exist before they're used? (they're consumed in HoverCardOverlay so that the animation of top/bottom can be pure CSS instead the hacky forced reflow with JS like Popover does.
08c0259
to
d38a750
Compare
Localization quality issues found The following issues may affect the quality of localized translations if they are not addressed:
Please look out for other instances of this issue in your PR and fix them as well if possible. Questions about these messages? Hop in the #help-localization Slack channel. |
WHY are these changes introduced?
This PR unblocks the new
HoverCard
component, which needs to be able to be positioned left and right of table cells.WHAT is this pull request doing?
Adds support for horizontal positioning of positioned overlays.
Demos
hovercard-demo-position-right-responsive-alignment.mp4
How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Click to view Playground code used for the above demos
🎩 checklist
README.md
with documentation changes