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] Use usePickerContext() to get the view-related props in the layout, toolbar and tabs slots #15606

Merged
merged 17 commits into from
Dec 19, 2024

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Nov 26, 2024

Part of #15495

What?

  • Use usePickerContext() for the view props in all the XXXTabs components
  • Use usePickerContext() for the view props in all the XXXToolbar components
  • Use usePickerContext() for the view props in usePickerLayout()

Why?

  • Prepares for composition
  • Removes TView from a lot of interfaces (about half of all the interfaces with TView were only needing it because of the tabs and toolbar slots...)
  • Prevents unwanted override of internal props using slotProps

What's next?

  • Do the same with the props handled by usePickerValue()
  • And then the whole layout part of the UI will be 100% context-based 🥳 (next we will have all the props forwarded to the field and to the views 😆 )

@flaviendelangle flaviendelangle added breaking change component: pickers This is the name of the generic UI component, not the React module! labels Nov 26, 2024
@flaviendelangle flaviendelangle self-assigned this Nov 26, 2024
@mui-bot
Copy link

mui-bot commented Nov 26, 2024

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 28, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 10, 2024
@flaviendelangle flaviendelangle changed the title [pickers] Remove view props from the <PickersLayout /> props and use the context instead [pickers] Use usePickerContext() to get the view-related props in the layout, toolbar and tabs slots Dec 10, 2024
@flaviendelangle flaviendelangle marked this pull request as ready for review December 10, 2024 18:32
@flaviendelangle flaviendelangle marked this pull request as draft December 10, 2024 18:32
@flaviendelangle flaviendelangle marked this pull request as ready for review December 11, 2024 08:22
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 19, 2024
Copy link
Member

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

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

nothing blocking ... feel free to ignore, when it's not relevant ... LGTM

function CustomLayout(props) {
- console.log(props.isRtl);

- const { isRtl } = props;
Copy link
Member

Choose a reason for hiding this comment

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

this is pure mind-bending ... a diff from a diff! 🤯

export const DateTimePickerToolbarOverrideContext = React.createContext<{
forceDesktopVariant: boolean;
onViewChange: (view: DateOrTimeViewWithMeridiem) => void;
view: DateOrTimeViewWithMeridiem | null;
Copy link
Member

Choose a reason for hiding this comment

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

is there a way we can remove the | null here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nop, the DateTimeRangePickerToolbar passes null when you are editing the other date

flaviendelangle and others added 6 commits December 19, 2024 16:35
Co-authored-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
Co-authored-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
Co-authored-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
Co-authored-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
…ar.tsx

Co-authored-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
…ar.tsx

Co-authored-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 19, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 19, 2024
@flaviendelangle flaviendelangle merged commit 695f807 into mui:master Dec 19, 2024
18 checks passed
@flaviendelangle flaviendelangle deleted the layout-view-props branch December 19, 2024 17:36
lauri865 pushed a commit to lauri865/mui-x that referenced this pull request Dec 20, 2024
…he layout, toolbar and tabs slots (mui#15606)

Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
Co-authored-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com>
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!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants