-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat(explorer): updated drawer header with dropdown menu #113637
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
Changes from all commits
b1bf1e9
1425be0
063e7aa
a4406f7
e9205a4
94fbe72
738e05a
d622bea
bb267fe
7cd4921
52d75ab
420a3ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,11 @@ export interface MenuItemProps extends MenuListItemProps { | |
| * Pass a class name to the menu item. | ||
| */ | ||
| className?: string; | ||
| /** | ||
| * Whether to close the menu when this item is clicked. Overrides the list-level | ||
| * `closeOnSelect` prop when set. | ||
| */ | ||
| closeOnSelect?: boolean; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this override necessary when we can just set the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the item-level closeOnSelect wasn't available before, only an option for closeOnSelect on all items. For all items except history, we want to close on select |
||
| /** | ||
| * Destination if this menu item is an external link. | ||
| */ | ||
|
|
@@ -111,17 +116,27 @@ export function DropdownMenuItem({ | |
| const innerWrapRef = useRef<HTMLDivElement | null>(null); | ||
| const isDisabled = state.disabledKeys.has(node.key); | ||
| const isFocused = state.selectionManager.focusedKey === node.key; | ||
| const {key, onAction, to, label, isSubmenu, trailingItems, externalHref, ...itemProps} = | ||
| node.value ?? {}; | ||
| const { | ||
| key, | ||
| onAction, | ||
| to, | ||
| label, | ||
| isSubmenu, | ||
| trailingItems, | ||
| externalHref, | ||
| closeOnSelect: itemCloseOnSelect, | ||
| ...itemProps | ||
| } = node.value ?? {}; | ||
| const {size} = node.props; | ||
| const {rootOverlayState} = useContext(DropdownMenuContext); | ||
| const isLink = to || externalHref; | ||
| const resolvedCloseOnSelect = itemCloseOnSelect ?? closeOnSelect; | ||
|
|
||
| const actionHandler = () => { | ||
| if (isLink) { | ||
| // Close the menu after the click event has bubbled to the link | ||
| // Only needed on links that do not unmount the menu | ||
| if (closeOnSelect) { | ||
| if (resolvedCloseOnSelect) { | ||
| requestAnimationFrame(() => rootOverlayState?.close()); | ||
| } | ||
| return; | ||
|
|
@@ -180,7 +195,7 @@ export function DropdownMenuItem({ | |
| onClose?.(); | ||
| rootOverlayState?.close(); | ||
| }, | ||
| closeOnSelect: isLink ? false : closeOnSelect, | ||
| closeOnSelect: isLink ? false : resolvedCloseOnSelect, | ||
| isDisabled, | ||
| }, | ||
| state, | ||
|
|
||
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.
More of a general design question - Any reason why we chose to hide the close button text instead of keeping it consistent everywhere?
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.
Was matching the figma - personally I think it looks cleaner, but don't have a strong preference