-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[pickers] Refactor owner state typing #17517
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
Conversation
Deploy preview: https://deploy-preview-17517--material-ui-x.netlify.app/ |
@@ -9,7 +9,7 @@ import { | |||
openPicker, | |||
stubMatchMedia, | |||
} from 'test/utils/pickers'; | |||
import { pickerPopperClasses } from '@mui/x-date-pickers/internals/components/PickerPopper'; | |||
import { pickerPopperClasses } from '@mui/x-date-pickers/internals'; |
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.
This wasn't causing issues and, for some reason, didn't even trigger ESLint issue, even though it should have. 🤔
During my ownerState rework, I did not add the ownerState to any element that did not have them. For me the question is more: is it worth doing? |
@flaviendelangle I have kept the 1st question as is and addressed the 2nd one as I saw best - aligning with the existing |
<PickersFadeTransitionGroupRoot className={clsx(classes.root, className)}> | ||
<PickersFadeTransitionGroupRoot | ||
className={clsx(classes.root, className)} | ||
ownerState={{ ...other }} |
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 did not want the ownerState
receiving the children
prop, it seemed counter intuitive. 🙈
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.
What is the benefit of spreading here?
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 you mean I'm passing ownerState
at all?
Or why not store it in a variable and pass it?
P.S. Any styled
component needs ownerState
to adhere to the exposed styleOverrides
contract.
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 have moved the ownerState
declaration outside of JSX.
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.
No my question was why ownerState={{ ...other }}
instead of ownerState={other}
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.
Whoops, sorry for my "broken brain" that day. 🙈
I will address it with the next PR. 😉
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
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 👌
Fixes #17297.
Before
After
Open questions
ownerState
to thestyled
elements, which are accessible bystyleOverrides
.This causes issues, because the "contract", that
styleOverrides
exposes is not "held".Q: Should we add the missing
ownerState
to everystyled
element available forstyleOverrides
?Resolution: Keeping this situation as is until explicit requests.
styled
elements and are available throughstyleOverrides
, however, they do not have anyownerState
passed to them, not even the root component.Q: Should we remove
styleOverrides
typing for them or pass theownerState
?Resolution: Passed some
ownerState
at least to the root element (definedOwnerState
in case ofMuiPickersSlideTransition
).MuiDayCalendarSkeleton
MuiPickersFadeTransitionGroup
MuiPickersSlideTransition
MuiPickersToolbarButton
MuiPickersToolbarText