-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Fix disableOpenPicker
prop behavior
#13212
Changes from all commits
0616a78
8dd6224
88a42a2
0653ee4
c7279e1
4c3da18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,8 +99,7 @@ export interface UsePickerViewsProps< | |
TView extends DateOrTimeViewWithMeridiem, | ||
TExternalProps extends UsePickerViewsProps<TValue, TDate, TView, any, any>, | ||
TAdditionalProps extends {}, | ||
> extends UsePickerViewsBaseProps<TValue, TDate, TView, TExternalProps, TAdditionalProps>, | ||
UsePickerViewsNonStaticProps { | ||
> extends UsePickerViewsBaseProps<TValue, TDate, TView, TExternalProps, TAdditionalProps> { | ||
className?: string; | ||
sx?: SxProps<Theme>; | ||
} | ||
|
@@ -141,8 +140,7 @@ export interface UsePickerViewParams< | |
|
||
export interface UsePickerViewsResponse<TView extends DateOrTimeViewWithMeridiem> { | ||
/** | ||
* Does the picker have at least one view that should be rendered in UI mode ? | ||
* If not, we can hide the icon to open the picker. | ||
* Indicates if the the picker has at least one view that should be rendered in UI. | ||
*/ | ||
hasUIView: boolean; | ||
renderCurrentView: () => React.ReactNode; | ||
|
@@ -185,7 +183,7 @@ export const usePickerViews = < | |
TAdditionalProps | ||
>): UsePickerViewsResponse<TView> => { | ||
const { onChange, open, onClose } = propsFromPickerValue; | ||
const { views, openTo, onViewChange, disableOpenPicker, viewRenderers, timezone } = props; | ||
const { views, openTo, onViewChange, viewRenderers, timezone } = props; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may be able to simplify the typing and get rid of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for noting it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not exactly Or maybe I'm missing something, I did not dive deeper tbh There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Mobile, it currently doesn't change anything, but on range pickers, it prevents the picker from opening on click. 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
const { className, sx, ...propsToForwardToView } = props; | ||
|
||
const { view, setView, defaultView, focusedView, setFocusedView, setValueAndGoToNextView } = | ||
|
@@ -203,9 +201,7 @@ export const usePickerViews = < | |
views.reduce( | ||
(acc, viewForReduce) => { | ||
let viewMode: 'field' | 'UI'; | ||
if (disableOpenPicker) { | ||
viewMode = 'field'; | ||
} else if (viewRenderers[viewForReduce] != null) { | ||
if (viewRenderers[viewForReduce] != null) { | ||
viewMode = 'UI'; | ||
} else { | ||
viewMode = 'field'; | ||
|
@@ -220,7 +216,7 @@ export const usePickerViews = < | |
}, | ||
{ hasUIView: false, viewModeLookup: {} as Record<TView, 'field' | 'UI'> }, | ||
), | ||
[disableOpenPicker, viewRenderers, views], | ||
[viewRenderers, views], | ||
); | ||
|
||
const timeViewsCount = React.useMemo( | ||
|
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.
The addition of the test allowed me to discover this "bug"—the
slotProps.layout.classes
were not used in the case ofDesktopDateTimePicker
andDesktopDateTimeRangePicker
. 🙈