-
Notifications
You must be signed in to change notification settings - Fork 604
ActionMenu: Add position callback as prop #5910
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 0ae6250 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks! |
size-limit report 📦
|
useEffect(() => { | ||
if (position && onPositionChange && position.anchorSide !== anchorSide) { | ||
setAnchorSide(position.anchorSide) | ||
onPositionChange(position) | ||
} | ||
}, [position, onPositionChange, anchorSide]) |
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.
I think this might fall under this category: https://react.dev/learn/you-might-not-need-an-effect#notifying-parent-components-about-state-changes
Would it be possible to call onPositionChange
and setAnchorSide
in response to some event?
<ActionMenu.Anchor> | ||
<IconButton icon={KebabHorizontalIcon} aria-label="Open menu" /> | ||
</ActionMenu.Anchor> | ||
<ActionMenu.Overlay onSideChange={onSideChange}> |
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.
Super random, it seemed like we have onSideChange
and onPositionChange
but I wasn't sure which is which. If you have a sec could you explain more? Also happy to read if I missed a section describing this 👀 (and sorry if so!)
Closes #5905
Adds a new prop
onSideChange
which allows consumers to provide a callback that is called when the position of theOverlay
changes inActionMenu
.The intent of this PR is to give consumers the current position of the overlay so that they can know where the menu will appear and adjust accordingly.
Changelog
New
onSideChange
Rollout strategy
Testing & Reviewing
Merge checklist