-
Notifications
You must be signed in to change notification settings - Fork 222
feat(compass-context-menu): add a headless context menu package COMPASS-9386 #6937
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
export function useContextMenu({ | ||
Menu, | ||
}: { | ||
Menu: React.ComponentType<{ |
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 guess we could keep it headless by letting it accept a component?
Open to a cleaner solution
c824499
to
647306f
Compare
(Content, index) => <Content key={`menu-content-${index}`} /> | ||
), | ||
position: { | ||
// TODO: Fix handling offset while scrolling |
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.
Not too sure what this was referring to, just came from the prototype
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 it's a reminder to check how this functions if the menu is displayed inside a view which is scrolled 🤔
31f6adf
to
43023f4
Compare
82a10c5
to
ca1fb86
Compare
…p menu state consistent The refactor is meant to make the Leafygreen integration more straightforward: 1. We stick to item groups and instead have a single wrapper to handle any rendering differences between groups. This allows the wrapper to always have context of all items when rendering which is useful when inserting menu seperators in Leafygreen. Also encourages consistent UI (while allowing per-case customization if needed at wrapper-level). We could introduce itemWrappers instead of itemGroups but having one wrapper handling all seems cleaner to me. 2. More of the responsibility is moved to a parent wrapper component that will house the context menu. This allows us to standardize the right click menu and make better use of Leafygreen's menu component including its click handling (which has been removed from the context menu library). 3. Menu state (i.e. position) is now preserved even closed; this is useful for leafygreen's menu to animate in the same position instead of losing the position all together.
ca1fb86
to
ee658e1
Compare
This acts as the headless basis for #6956 right click component
TODO: