-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 slots in the mobile and desktop wrappers instead of XXXComponent
and XXXProps
#6381
[pickers] Use slots in the mobile and desktop wrappers instead of XXXComponent
and XXXProps
#6381
Conversation
These are the results for the performance tests:
|
PickersPopper
and PickersModalDialog
[WIP]
PickersPopper
and PickersModalDialog
[WIP]XXXComponent
and XXXProps
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.
Sounds good. I'm just wondering is PaperContent
is still relevant or is it can be replaced by desktopPaper
and mobilePaper
Not related to this PR (was there before) but I saw it when reading slot doc preview. The api page ends with
The component cannot hold a ref.
Even if DatePicker
are wrapped into a React.forwardRef
elevation={8} | ||
ref={handlePaperRef} | ||
<Transition {...TransitionProps} {...componentsProps?.desktopTransition}> | ||
<Paper | ||
{...paperProps} | ||
onClick={(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => { | ||
onPaperClick(event); | ||
if (onPaperClickProp) { | ||
onPaperClickProp(event); | ||
} | ||
paperProps.onClick?.(event); | ||
}} | ||
onTouchStart={(event: React.TouchEvent<HTMLDivElement>) => { | ||
onPaperTouchStart(event); | ||
if (onPaperTouchStartProp) { | ||
onPaperTouchStartProp(event); | ||
} | ||
paperProps.onTouchStart?.(event); | ||
}} | ||
ownerState={{ ...ownerState, placement }} | ||
className={classes.paper} | ||
{...otherPaperProps} | ||
> | ||
<PaperContent {...componentsProps?.paperContent}> |
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.
Why not merging Paper
and PaperContent
in a single element?
If I remember correctly, the PaperContent
being a Fragment
was just to avoid breaking changes. Now we are allowed to break it's the opportunity
@LukasTy Was there another reason?
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.
After many discussions and experimentations—let's isolate this PR only for the refactor of props -> slots.
Merging Paper
and PaperContent
is not trivial as Static
pickers do not have a wrapping Paper.
And we also have the issue of possibly having difficulties changing component layout once we flatten the structure of sub-components.
I think then will be the time to revisit this topic and look into a way of having a homogenous approach towards overriding/slots.
PaperComponent={components?.MobilePaper} | ||
PaperProps={componentsProps?.mobilePaper} |
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.
If we keep the contentPaper
should it also apply on mobile?
PaperComponent={components?.MobilePaper} | |
PaperProps={componentsProps?.mobilePaper} | |
PaperComponent={components?.MobilePaper ?? components?.ContentPaper} | |
PaperProps={componentsProps?.mobilePaper ?? componentsProps?.contentPaper} |
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.
@LukasTy was in favor not to because the layout wanted are often different
I will explain better than me
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.
PaperContent
could possibly be added to the mobile pickers as well.
It could be up to the user to decide when to display it or not using CSS if it is needed.
packages/x-date-pickers/src/internals/components/PickersPopper.tsx
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/components/PickersPopper.tsx
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/components/PickersPopper.tsx
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/components/PickersPopper.tsx
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/components/PickersPopper.tsx
Outdated
Show resolved
Hide resolved
Pour le rôle de |
@@ -50,7 +50,7 @@ | |||
"test:performance:server": "serve test/performance -p 5001", | |||
"test:argos": "node ./scripts/pushArgos.js", | |||
"typescript": "lerna run --no-bail --parallel typescript", | |||
"typescript:ci": "lerna run --concurrency 7 --no-bail --no-sort typescript", | |||
"typescript:ci": "lerna run --concurrency 6 --no-bail --no-sort typescript", |
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 reason behind this change? 🤔
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 a 137 TS error (out of memory)
And I can't find how to fix it without reducing the concurrency.
If you have a better solution 😬
packages/x-date-pickers/src/internals/components/wrappers/WrapperProps.ts
Outdated
Show resolved
Hide resolved
elevation={8} | ||
ref={handlePaperRef} | ||
<Transition {...TransitionProps} {...componentsProps?.desktopTransition}> | ||
<Paper | ||
{...paperProps} | ||
onClick={(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => { | ||
onPaperClick(event); | ||
if (onPaperClickProp) { | ||
onPaperClickProp(event); | ||
} | ||
paperProps.onClick?.(event); | ||
}} | ||
onTouchStart={(event: React.TouchEvent<HTMLDivElement>) => { | ||
onPaperTouchStart(event); | ||
if (onPaperTouchStartProp) { | ||
onPaperTouchStartProp(event); | ||
} | ||
paperProps.onTouchStart?.(event); | ||
}} | ||
ownerState={{ ...ownerState, placement }} | ||
className={classes.paper} | ||
{...otherPaperProps} | ||
> | ||
<PaperContent {...componentsProps?.paperContent}> |
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.
After many discussions and experimentations—let's isolate this PR only for the refactor of props -> slots.
Merging Paper
and PaperContent
is not trivial as Static
pickers do not have a wrapping Paper.
And we also have the issue of possibly having difficulties changing component layout once we flatten the structure of sub-components.
I think then will be the time to revisit this topic and look into a way of having a homogenous approach towards overriding/slots.
PaperComponent={components?.MobilePaper} | ||
PaperProps={componentsProps?.mobilePaper} |
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.
PaperContent
could possibly be added to the mobile pickers as well.
It could be up to the user to decide when to display it or not using CSS if it is needed.
Part of #4466
Needed for #6070
Doc preview of the DatePicker slots
Desktop
props.PaperProps
bycomponentsProps.desktopPaper
(add addcomponents.DesktopPaper
for consistency)props.PopperProps
bycomponentsProps.popper
(and addcomponents.Popper
for consistency)props.TransitionComponent
bycomponents.DesktopTransition
, it is not used on mobile ! (and add acomponentsProps.transition
for consistency)props.TrapFocusProps
bycomponentsProps.desktopTrapFocus
, this prop was missing from the public component signature btw (and add acomponents.DesktopTrapFocus
for consistency)Mobile
props.DialogProps
bycomponentsProps.Dialog
(and addcomponents.dialog
for consistency)components.MobileTransition
andcomponentsProps.mobileTransition
(in the tests we were usingprops.DialogProps.TransitionProps
which was not consistent with the desktop transition which was usingprops.TransitionProps
).components.MobilePaper
andcomponentsProps.mobilePaper
(replaces [pickers] UsePaperProps
in mobile pickers #6223)Changelog
Breaking changes
All the props used by the mobile and desktop wrappers to override components or components props has been replaced by component slots. You can find more information about this pattern in the MUI Base documentation.
Some of the names have also been prefixed by
desktop
when it was unclear that the behavior was only applied on the desktop version of the pickers (or the responsive version when used on a desktop).The
DialogProps
prop has been replaced by adialog
component props slot on a responsive an mobile pickers:The
PaperProps
prop has been replaced by adesktopPaper
component props slot on all responsive and desktop pickers:The
PopperProps
prop has been replaced by apopper
component props slot on all responsive and desktop pickers:The
TransitionComponent
prop has been replaced by aDesktopTransition
component slot on all responsive and desktop pickers:The
TrapFocusProps
prop has been replaced by adesktopTrapFocus
component props slot on all responsive and desktop pickers: