-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Create new component PickersSectionList
#11352
[pickers] Create new component PickersSectionList
#11352
Conversation
Deploy preview: https://deploy-preview-11352--material-ui-x.netlify.app/ |
outline: 'none', | ||
flexGrow: 1, | ||
...(theme.direction === 'rtl' && { textAlign: 'right /*! @noflip */' as any }), |
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.
Small fix for RTL
@@ -70,11 +72,13 @@ const PickersInputSectionsContainer = styled('div', { | |||
slot: 'SectionsContainer', | |||
overridesResolver: (props, styles) => styles.sectionsContainer, | |||
})<{ ownerState: OwnerStateType }>(({ theme, ownerState }) => ({ | |||
direction: 'ltr /*! @noflip */' as any, |
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.
Small fix for RTL
I try to do the value flip in JS and render always in LTR
@@ -46,6 +46,8 @@ const PickersInputRoot = styled(Box, { | |||
borderWidth: 2, | |||
}, | |||
[`&.${pickersInputClasses.disabled}`]: { | |||
pointerEvents: 'none', |
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.
We had hover effect when disabled
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.
Do we by any chance also need appropriate adjustments to the onChange
handler to not work when the field is disabled
or readonly
, but user manually removes the class from DOM?
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.
In the onInput
handler (equivalent of onChange
for contentEditable
elements), we have conditions for readOnly
, I can add some for disabled
to be more robust.
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.
Makes sense. 👍
|
||
export const pickersSectionListClasses = generateUtilityClasses<PickersSectionListClassKey>( | ||
'MuiPickersSectionList', | ||
['sectionContent'], |
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.
I'm adding this class because the field should never rely on PickersInput
since people can pass custom ones.
I'll probably add a root
one
@@ -135,7 +135,7 @@ export const PickersTextField = React.forwardRef(function PickersTextField( | |||
fullWidth={fullWidth} | |||
inputProps={inputProps} | |||
inputRef={inputRef} | |||
sectionsContainerRef={sectionsContainerRef} | |||
sectionListRef={sectionListRef} |
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.
I renamed this prop to match the component name
PickersSectionsList
PickersSectionList
4194ac6
to
20eb708
Compare
20eb708
to
de1111c
Compare
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.
Looks good! 🎉
Very small nitpick, what do you think about calling this component PickersSectionsList
and keep the plural form?
I'd be curious to have @LukasTy opinion on the naming. |
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.
LGTM! 👍
I'd be curious to have LukasTy opinion on the naming.
For me, it's a list of thing, not a list of things, so "section list" instead of "sections list".
But I'm not a native speaker
I'm also not a native speaker, but am a bit torn on this one. 🙈
When in doubt, I like to check the number of google search results to help guide my decision. 🤷
In this case, "Section List" clearly takes the lead.
However, my gut also leans towards PickersSectionsLIst
for this particular component, but I think that both forms are correct in this case and I do not urge changing it. 👍
packages/x-date-pickers/src/PickersSectionList/PickersSectionList.tsx
Outdated
Show resolved
Hide resolved
@@ -46,6 +46,8 @@ const PickersInputRoot = styled(Box, { | |||
borderWidth: 2, | |||
}, | |||
[`&.${pickersInputClasses.disabled}`]: { | |||
pointerEvents: 'none', |
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.
Do we by any chance also need appropriate adjustments to the onChange
handler to not work when the field is disabled
or readonly
, but user manually removes the class from DOM?
My thoughts on the naming: I often see strung-together plurals like |
187f5d3
to
700d8b5
Compare
700d8b5
to
f48c9a8
Compare
The idea is that
useField
expectsPickersSectionList
to be used but it does not care aboutPickersTextField
/PickersInput
.So the Joy implementation (or unstyled one) can have whatever structure they want, as long as they use
PickersSectionList
.Right now
useField
imports classes fromPickersInput
which is link to Material Design.