-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Input][joy-ui] Display decorators when passed in slots #38295
Conversation
Netlify deploy previewhttps://deploy-preview-38295--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
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.
It's fine for a fix, but we can likely re-think if we need both APIs or not. cc @siriwatknp
packages/mui-joy/src/Input/Input.tsx
Outdated
@@ -334,12 +334,14 @@ const Input = React.forwardRef(function Input(inProps, ref) { | |||
|
|||
return ( | |||
<SlotRoot {...rootProps}> | |||
{startDecorator && ( | |||
{(startDecorator ?? startDecoratorProps.ownerState.slots?.startDecorator) && ( |
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.
{(startDecorator ?? startDecoratorProps.ownerState.slots?.startDecorator) && ( | |
{(startDecorator ?? slots?.startDecorator) && ( |
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.
fixed in this commit 885f0a9
packages/mui-joy/src/Input/Input.tsx
Outdated
<SlotStartDecorator {...startDecoratorProps}>{startDecorator}</SlotStartDecorator> | ||
)} | ||
|
||
<SlotInput {...inputProps} /> | ||
{endDecorator && <SlotEndDecorator {...endDecoratorProps}>{endDecorator}</SlotEndDecorator>} | ||
{(endDecorator ?? endDecoratorProps.ownerState.slots?.endDecorator) && ( |
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.
{(endDecorator ?? endDecoratorProps.ownerState.slots?.endDecorator) && ( | |
{(endDecorator ?? slots?.endDecorator) && ( |
@@ -334,12 +334,14 @@ const Input = React.forwardRef(function Input(inProps, ref) { | |||
|
|||
return ( | |||
<SlotRoot {...rootProps}> | |||
{startDecorator && ( | |||
{(startDecorator ?? slots?.startDecorator) && ( |
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 think we should not do this. The intention of slots.*
is to replace the default slot component, there shouldn't be other logic involved.
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.
Okay, should we add something in docs explaining same? I think it's confusing right now
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.
Agree!
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 already have the overall doc about slots
at https://mui.com/joy-ui/customization/overriding-component-structure/.
We could add a note on the Input page under the decorator section.
See my comment on why we should drop this PR (feel free to comment your thought as well) |
|
closes: #38281
before: https://codesandbox.io/s/ecstatic-flower-kvkz48?file=/Demo.js:0-361
after: https://codesandbox.io/s/wizardly-robinson-rpwfcy?file=/Demo.tsx