-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[material-ui][Tabs] Deprecate *Props and complete slots
, slotProps
#45012
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy previewTabList: parsed: +1.21% , gzip: +1.15% Bundle size reportDetails of bundle changes (Toolpad) |
}, | ||
indicator: { | ||
expectedClassName: classes.indicator, | ||
}, |
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 tests for scrollButton
, startScrollButtonIcon
, endScrollButtonIcon
are missing
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.
Added at the end of this file. I could not leverage describeConformance
because there are 2 scroll buttons when rendered, so the tests will fail due to queryByTestId
.
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, just left a comment
elementType: FlexContainer, | ||
externalForwardedProps, | ||
ownerState, | ||
getSlotProps: (handlers) => ({ |
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 use getSlotProps
here and not with other handlers?
Where do the handlers.onKeyDown?.(event)
come from? If it is from the props, then can we extract it and handle this on the handleKeyDown
definition?
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 use getSlotProps here and not with other handlers?
Because only flexContainer
slot has onKeyDown
logic in this component.
Where do the handlers.onKeyDown?.(event) come from
Yes, it comes from slotProps.flexContainer
The intention of the change solely due to slotProps.*
could be a function. That's why getSlotProps
exists from MUI Base to ensure that handlers
is resolved to an object.
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.
Because only flexContainer slot has onKeyDown logic in this component.
But there are other event handlers, for example onChange
on the scroller
slot 🤔
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 guess you meant scrollbar
slot and I think your question is "why scrollbar does not have getSlotProp
given it receive onChange
" right?
Let me update it.
}, | ||
}); | ||
|
||
const [FlexContainerSlot, flexContainerSlotProps] = useSlot('flexContainer', { |
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 flexContainer
slot seems difficult to understand from the users perspective, would 'list' be a better name?
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 don't think so, this is because the slot is created with flexContainer
name. It's not a new slot.
// line: 198
const FlexContainer = styled('div', {
name: 'MuiTabs',
slot: 'FlexContainer',
overridesResolver: (props, styles) => {
const { ownerState } = props;
return [
styles.flexContainer,
ownerState.vertical && styles.flexContainerVertical,
ownerState.centered && styles.centered,
];
},
})({
So styleOverrides already work with flexContainer
slot. I think slots
and slotProps
should follow the same name.
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.
Could we deprecate styles.flexContainer
and change it? I really think it's a bad name as it doesn't explain to users what this slot's role is in the component: flexContainer
can be anything.
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.
Are you sure? that will increase the effort for writing a codemod to migrate styleOverrides. Given there is no complain about the flexContainer name so far, do you think it's worth to rename it @aarongarciah ?
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 agree it's not a good name. Let's change it now that we are at it 🙏
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.
@DiegoAndai let's do this in v7. Renaming flexContainer
to list
for the styleOverrides altogether now will be a breaking change.
part of #41281
root, scroller, flexContainer, scrollbar, indicator, scrollButtons, startScrollButtonIcon, endScrollButtonIcon
.These are existing slots and classes.