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] Replace the onOpen() and onClose() methods of usePickerContext() with a single setOpen() method #15701

Merged
merged 10 commits into from
Dec 4, 2024

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Dec 2, 2024

While working on #15671, I started to duplicate a lot the handleTogglePicker method.

@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
@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

Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

I think we were discussing this exact topic when we were initially introducing the other methods. 😃
I can't think of any harm providing it, if we already feel that it is cleaner in most regular cases. 👌

@flaviendelangle
Copy link
Member Author

I think we were discussing this exact topic when we were initially introducing the other methods. 😃

Yes, we were debating between an onToggleXXX and onOpen + onClose.
I think we did the right move to provide onOpen + onClose, but now I think providing both is even better 😆

@flaviendelangle flaviendelangle changed the title [pickers] Add new method onToggleOpening to usePickerContext() [pickers] Replace the onOpen() and onClose() methods of usePickerContext() with a single setOpen() method. Dec 4, 2024
@@ -8,7 +8,7 @@ export interface OpenStateProps {

export const useOpenState = ({ open, onOpen, onClose }: OpenStateProps) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

No behavior change, I just aligned the wording a bit

@LukasTy LukasTy added breaking change enhancement This is not a bug, nor a new feature v8.x labels Dec 4, 2024
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

Nice final result, great job! 👍 💯
I think such cleaner type of API should be sufficient enough and will avoid "analysis-paralysis" (what do I use now... 🤔)😆

@flaviendelangle flaviendelangle merged commit 18a71ef into mui:master Dec 4, 2024
18 checks passed
@flaviendelangle flaviendelangle deleted the ctx-onToggleOpening branch December 4, 2024 10:42
@oliviertassinari oliviertassinari changed the title [pickers] Replace the onOpen() and onClose() methods of usePickerContext() with a single setOpen() method. [pickers] Replace the onOpen() and onClose() methods of usePickerContext() with a single setOpen() method Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature v8.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants