Skip to content
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

[pickers] Add new method onToggleOpening to usePickerContext() #15701

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

flaviendelangle
Copy link
Member

While working on #15671, I started to duplicate a lot the handleTogglePicker method.
WDYT about exposing both onOpen / onClose / open AND the onToggleOpening method.
It cleans our doc demos a bit to focus on the interesting part and I guess most people would prefer to use the shortcut anyway.

@flaviendelangle flaviendelangle added the component: pickers This is the name of the generic UI component, not the React module! label Dec 2, 2024
@flaviendelangle flaviendelangle self-assigned this Dec 2, 2024
@@ -67,6 +68,14 @@ export function usePickerProvider<TValue extends PickerValidValue>(
const utils = useUtils();
const orientation = usePickerOrientation(views, props.orientation);

const handleTogglePicker = useEventCallback((event: React.UIEvent) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be an action exposed by usePickerValue but it has more implications (all actions are forwarded to PickersPopper for now.
Until the actions are always accessed through the state, I propose to keep it here to avoid problems.

@flaviendelangle flaviendelangle marked this pull request as ready for review December 2, 2024 16:16
@flaviendelangle flaviendelangle changed the title [pickers] Add new method onToggleOpening to the picker public context [pickers] Add new method onToggleOpening to usePickerContext() Dec 2, 2024
@mui-bot
Copy link

mui-bot commented Dec 2, 2024

Deploy preview: https://deploy-preview-15701--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against aeddc0d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants