-
Notifications
You must be signed in to change notification settings - Fork 981
[ContextMenu][DropdownMenu] Integrate new submenu parts #629
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
Conversation
861f8b6
to
d04f58c
Compare
e2e6f94
to
79a120a
Compare
b06cdc7
to
732c76c
Compare
89c730c
to
38b7c67
Compare
0f554f9
to
2b43c97
Compare
38b7c67
to
e466b7c
Compare
94b3a0c
to
4e53fa9
Compare
@jjenzz @benoitgrelard – This one is also ready. Might be easier to review after we've worked through #627 though! |
b326bd8
to
a4f0f6f
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.
Initial bits. Love how simple these changes were! Although, I'm a bit worried about the TS issues with the trigger parts, need to think about that some 😬
const DropdownMenu: React.FC<DropdownMenuOwnProps> = (props) => { | ||
const parentSubmenuContext = React.useContext(SubmenuContext); | ||
return ( | ||
<SubmenuContext.Provider value={parentSubmenuContext === undefined ? false : true}> |
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.
In fact.... 💭
const SubmenuContext = React.createContext(false);
// ...
const isSubmenu = React.useContext(SubmenuContext);
<SubmenuContext.Provider value={isSubmenu}>
I remember we did this undefined
check for ContextMenu
because we needed to check if it was undefined
to determine isRoot
but we don't need that in DropdownMenu
right?
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 same applies here, we need undefined
to determine the root, else it'll always fall one way or the other.
const DropdownMenu: React.FC<DropdownMenuOwnProps> = (props) => { | ||
const parentMenuContext = React.useContext(SubmenuContext); | ||
return ( | ||
<SubmenuContext.Provider value={parentMenuContext === undefined ? false : true}> |
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 can't see a const isRoot = parentContext === undefined
check anywhere in dropdown menu hence my confusion as to why we need parentMenuContext
to be undefined
. Can you help me understand this part?
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.
In the previous config we needed to have an additional state available for the first render to know if the context even exists, hence the undefined
, but wrapping the content means we can do it after that point, so we implicitly know it's root. f9061af
* [Menu] Add submenu primitives (#627) Co-authored-by: Jenna Smith <[email protected]> * [Menu] Provide predictable typeahead scoping (#662) * Scope typeahead via collection * Exclude only on typeahead space key * Simplify typeahead * Prevent continuous `updateSearch` call * Inline `onExclusiveKeyDown` functionality * Clear search buffer when leaving * Move `MenuSubTrigger` code below `MenuContent` * `isTypingAhead` conditional clarity * [ContextMenu][DropdownMenu] Integrate new submenu parts (#629) * [ContextMenu][DropdownMenu] Add `TriggerItem` part (#683) * [ContextMenu][DropdownMenu] Don't close on sub trigger pointer down (#684) Co-authored-by: Jenna Smith <[email protected]> * [ContextMenu][DropdownMenu] Add pointer grace for navigation to sub-menus (#688) * [ContextMenu][DropdownMenu] delay sub trigger open via pointer * Add pointer area grace * Use clientX/Y rather than pageX/Y because getBoundingClientRect doesn't include scroll * Update DropdownMenu.stories.tsx * feedback * onItemEnter * Update Menu.tsx * more explicit open timer ref * Remove content rect caching * Move MenuItemImpl down (#689) * [DropdownMenu] Add `aria-labelledby` to follow spec (#692) * Add `aria-labelledby` * Follow `aria-expanded` spec for submenu triggers * Updates based on feedback * Rename root context type * [ContextMenu] Bring inline with `DropdownMenu` changes (#693) * Remove `ArrowUp` to open (#702) * [DropdownMenu] Enable `onEntryFocus` for root menu (#694) * Focus first item when all content types open for keyboard users * Initial feedback addressed * Add `pointerdown` to keyboard user logic * Remove capture * Re-apply capture events with comment * [ContextMenu][DropdownMenu] Improve pointer grace (#691) * Share grace timer ref in content * Align pointer behaviour closer with native * Simplify base story for easier test * Remove export of private func * Tidy from feedback * Minor naming adjustment * Apply `useCallback` Co-authored-by: Andy Hook <[email protected]> * [ContextMenu][DropdownMenu] Fix menu focus after pointer interaction (#707) * Fix menu focus after pointer interaction * Add explainer * [Menu] Remove `onPointerDownOutside` on sub (#708) * [ContextMenu][DropdownMenu] Improve touch/mouse handling separation (#709) * [ContextMenu][DropdownMenu] Improve touch/mouse handling separation * Feedback * [DropdownMenu][ContextMenu] Unwind all nested menus with ESC * [Menu] Tidy `handleSelect` binding * [Menu] Remove callbackRef in handleSelect * [Menu] onSelect optional chain Co-authored-by: Jenna Smith <[email protected]> Co-authored-by: Benoît Grélard <[email protected]> Co-authored-by: Jenna Smith <[email protected]>
Builds on #627
Description
This PR uses the new submenu primitives from
Menu
to provide submenu support inContextMenu
andDropdownMenu
Approach
Menus can be nested to create sub menus.
Basic example
submenu-mouse-kb.mov