-
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
Update PositionedOverlay
to support HoverCard
positioning
#11758
Conversation
/snapit |
1 similar comment
/snapit |
🫰✨ Thanks @yurm04! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/[email protected] yarn add @shopify/[email protected] yarn add @shopify/[email protected] |
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 @yurm04! Changes brought over all look correct, except where noted that one of Kyle's recent changes was accidentally reverted. Do you have a Spinstance we can tophat? We also need to bring over the Tooltip change to the preferredPosition prop that only allows it to be above or below.
@@ -270,10 +289,9 @@ export class PositionedOverlay extends PureComponent< | |||
: this.firstScrollableContainer; | |||
const scrollableContainerRect = getRectForNode(scrollableElement); | |||
|
|||
const overlayRect = | |||
fullWidth || preferredPosition === 'cover' |
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 we need to bring in--this was part of Kyle's recent addition of cover
position.
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.
great catch! ty @chloerice 🙏
@kyledurand adding you as a reviewer to make sure I didn't bulldoze any of your recent changes
fullWidth || preferredPosition === 'cover' | ||
? new Rect({...currentOverlayRect, width: activatorRect.width}) | ||
: currentOverlayRect; | ||
const overlayRect = fullWidth |
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.
const overlayRect = fullWidth | |
fullWidth || preferredPosition === 'cover' |
/snapit |
🫰✨ Thanks @yurm04! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/[email protected] yarn add @shopify/[email protected] yarn add @shopify/[email protected] |
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.
Looks like this removes cover positioning. Might just be a bad rebase but not working when I tophat
@@ -17,12 +17,15 @@ import { | |||
import type {PreferredPosition, PreferredAlignment} from './utilities/math'; | |||
import styles from './PositionedOverlay.module.css'; | |||
|
|||
type Positioning = 'above' | 'below' | 'cover'; | |||
type Positioning = 'above' | 'below' | 'left' | 'right' | 'cover'; |
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.
Should these be start
end
?
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 isn't a hard opinion, but I think left
and right
make sense here because it is relative to the activator 🤔 but I'm not married to that and happy to change it to be consistent with the rest of our positioning props
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.
It matches with the actual css positioning as well so I'm fine with 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.
Commented the missing logic to bring over for preferredPosition="cover"
(locally tested diff of suggested changes for reference)
|
||
const chevronOffset = | ||
activatorRect.center.x - | ||
horizontalPosition + | ||
overlayMargins.horizontal * 2; | ||
|
||
let width = null; | ||
|
||
if (fullWidth) width = overlayRect.width; |
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.
if (fullWidth) width = overlayRect.width; | |
if (fullWidth || preferredPosition === 'cover') width = overlayRect.width; |
: spaceAbove - minimumSurroundingSpace; | ||
const heightIfBelow = enoughSpaceFromBottomEdge | ||
? desiredHeight - verticalMargins | ||
: spaceBelow - minimumSurroundingSpace; |
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.
: spaceBelow - minimumSurroundingSpace; | |
: spaceBelow - minimumSurroundingSpace; | |
const heightIfAboveCover = Math.min( | |
spaceAbove + activatorRect.height, | |
desiredHeight, | |
); | |
const heightIfBelowCover = Math.min( | |
spaceBelow + activatorRect.height, | |
desiredHeight, | |
); | |
const positionIfCoverBelow = { | |
height: heightIfBelowCover - verticalMargins, | |
top: activatorTop + containerRectTop, | |
positioning: 'cover', | |
}; | |
const positionIfCoverAbove = { | |
height: heightIfAboveCover - verticalMargins, | |
top: | |
activatorTop + | |
containerRectTop - | |
heightIfAbove + | |
activatorRect.height + | |
verticalMargins, | |
positioning: 'cover', | |
}; | |
if (preferredPosition === 'cover') { | |
return (enoughSpaceFromBottomEdge || | |
(mostSpaceOnBottom && | |
spaceBelow + activatorRect.height > desiredHeight) || | |
spaceBelow > spaceAbove) | |
? positionIfCoverBelow | |
: positionIfCoverAbove; | |
} |
@@ -20,133 +28,210 @@ export function calculateVerticalPosition( | |||
fixed: boolean | undefined, | |||
topBarOffset = 0, | |||
) { |
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.
Make TS happy in PositionedOverlay.tsx
) { | |
: { | |
top?: number; | |
bottom?: number; | |
height: number; | |
positioning: string; | |
} |
@yurm04, please make sure to prevent Tooltip from supporting left and right, as that is not UX that we want. TooltipOverlay.jsx preferredPosition?: 'above' | 'below'; |
Co-authored-by: Chloe Rice <[email protected]> Co-authored-by: Charles Lee <[email protected]>
Co-authored-by: Chloe Rice <[email protected]>
f9c8d99
to
fa4d0a7
Compare
/snapit |
🫰✨ Thanks @chloerice! Your snapshot has been published to npm. Test the snapshot by updating your "@shopify/polaris": "0.0.0-snapshot-20240417204842" |
fa4d0a7
to
ed1f843
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. |
Hi! We noticed there hasn’t been activity on this PR in a while. After 30 days, it will close automatically. If it’s still relevant, or you have updates, comment and let us know. And don’t worry, you can always re-open later if needed. |
WHY are these changes introduced?
Pulls in the updates to
PositionedOverlay
that were originally going to go out as part of theAlphaHoverCard
PRFixes #11748
WHAT is this pull request doing?
Adds
left
andright
positioning support for overlaysHow to 🎩
Check the local storybook and/or visit this spin and hover over the
Destination
cell to the theright
positioned HoverCard🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
🎩 checklist
README.md
with documentation changes