-
Notifications
You must be signed in to change notification settings - Fork 65
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 menu state to auto wrap popover usages with the menu state context provider #1030
base: master
Are you sure you want to change the base?
Update menu state to auto wrap popover usages with the menu state context provider #1030
Conversation
andrewkfiedler
commented
Mar 19, 2025
- This will automatically handle the majority of use cases, as most times in the application we are directly feeding popover props to a popover. Now those components within will automatically get wrapped with the relevant menu state context.
- For other uses, we provide MenuStateProviderInstance as a convenience for wrapping components with context.
- Updates some of the function calls to utilize useCallback when possible, to minimize rerenders.
- Adds some default implementations for the context functions that will show warnings to devs in the console if they happen to be used in a situation where menu state context is missing.
9cc336a
to
b29dd0a
Compare
build now |
Internal build has been started, your results will be available at build completion. |
setOpen(!open) | ||
} | ||
const handleClick = React.useCallback(() => { | ||
setOpen((currentValue) => { |
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.
Updated this one to a callback and used the ability to access previous value so we could keep the dependency array blank
MuiPopoverProps: { | ||
open, | ||
onClose: handleClose, | ||
anchorEl: anchorRef.current, | ||
action, | ||
ref: popoverRef.ref, | ||
...POPOVER_DEFAULTS({ maxHeight }), | ||
slotProps: { |
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 most cases we use these popover props, splatting them into the popover, so we'll now automatically get the menu context in those cases.
@@ -137,7 +199,10 @@ export function useMenuState({ maxHeight }: Props = {}) { | |||
ref: anchorRef, | |||
onClick: handleClick, | |||
}, | |||
MenuStateProviderInstance, |
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.
For other use cases not using popovers, we have this as a convenience for wrapping things with the menu context.
Build SUCCESS See the job results in legacy Jenkins UI or in Blue Ocean UI. |
b29dd0a
to
f5c5bb5
Compare
…text provider - This will automatically handle the majority of use cases, as most times in the application we are directly feeding popover props to a popover. Now those components within will automatically get wrapped with the relevant menu state context. - For other uses, we provide MenuStateProviderInstance as a convenience for wrapping components with context. - Updates some of the function calls to utilize useCallback when possible, to minimize rerenders. - Adds some default implementations for the context functions that will show warnings to devs in the console if they happen to be used in a situation where menu state context is missing. - Adds a convenient method for closing nested menus all at once - Removes unused better click away listener
f5c5bb5
to
92369f1
Compare
@@ -28,7 +28,6 @@ class SubscribableNavigationContextClass extends Subscribable<{ | |||
) { | |||
this.navigationContext = navigationContext | |||
this._notifySubscribers({ thing: 'update' }) | |||
console.log('updateNavigationContext', navigationContext) |
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.
Removing some chatty console logs that we don't need.