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

[core] Fix default props behavior on all pickers #4451

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Apr 11, 2022

Change showToolbar default value on DateTimePicker

Fixes #4455

It is simply a migration of mui/material-ui#30258
The default value was yet but the doc was saying otherwise

image

Apply same code structure for the DateRangePicker as on the other components

All others responsive picker components (TimePicker / DatePicker and DateTimePicker) are just tiny wrappers that calls there mobile and desktop components.

But for the range picker, we had duplication of a large interface + duplication of most code between DateRangePicker, MobileDateRangePicker and DesktopDateRangePicker.

Fix the props priority (component props > theme props > default props)

Fixes #4454

We currently do something like:

const useSomePickerDefaultizedProps = (
  { someProp = defaultValue, ...other },
  name
) => {
  return useThemeProps({ 
    props: { someProp, ...other },
    name
  })
}

So someProp is never undefined when passed to useThemeProps.

I changed it to:

const useSomePickerDefaultizedProps = (props, name) => {
  const themeProps = useThemeProps({ props, name })

  return { someProp: defaultValue, ...themeProps }
}

Others

I also replaced the ternaries by if in the other components.
I don't like the usage of ternaries for long expressions.

@flaviendelangle flaviendelangle added core Infrastructure work going on behind the scenes component: pickers This is the name of the generic UI component, not the React module! component: DateRangePicker The React component. labels Apr 11, 2022
@flaviendelangle flaviendelangle self-assigned this Apr 11, 2022
@mui-bot
Copy link

mui-bot commented Apr 11, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 247.2 518.8 319.2 364.96 111.259
Sort 100k rows ms 494.5 1,036.2 494.5 811.28 201.205
Select 100k rows ms 92.4 142.8 141.2 125.56 19.743
Deselect 100k rows ms 127.1 312.5 191.3 216.74 69.666

Generated by 🚫 dangerJS against 2556721

@flaviendelangle flaviendelangle changed the title [core] Refacto responsive behavior on DateRangePicker [core] Fix default props behavior on all pickers Apr 11, 2022
@flaviendelangle flaviendelangle added bug 🐛 Something doesn't work and removed core Infrastructure work going on behind the scenes labels Apr 11, 2022
@flaviendelangle flaviendelangle merged commit b2b9420 into mui:master Apr 12, 2022
@flaviendelangle flaviendelangle deleted the refacto-responsive-date-range-picker branch April 12, 2022 15:17
alexfauquette pushed a commit to alexfauquette/mui-x that referenced this pull request Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: DateRangePicker The React component. component: pickers This is the name of the generic UI component, not the React module!
Projects
None yet
3 participants