Skip to content
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

[TabScrollButton] Extend ButtonBase types #38719

Merged

Conversation

ZeeshanTamboli
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli commented Aug 30, 2023

I saw this while working on #38717. The TabScrollButton component uses ButtonBase, but it doesn't support its prop types.

Before: https://codesandbox.io/s/great-goldwasser-kqk4sz?file=/src/App.tsx
After: https://codesandbox.io/s/strange-shannon-tdy27s

Open the codesandboxes in full screen to get the scroll buttons.

@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work component: tabs This is the name of the generic UI component, not the React module! typescript package: material-ui Specific to @mui/material labels Aug 30, 2023
@mui-bot
Copy link

mui-bot commented Aug 30, 2023

Netlify deploy preview

https://deploy-preview-38719--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against fa84948

@ZeeshanTamboli ZeeshanTamboli marked this pull request as ready for review August 30, 2023 06:58
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me but a question came up. InternalStandardProps was replaced and the types it provides now come from CommonProps and ComponentPropsWithRef. My question is, is InternalStandardProps still useful or should we look into removing it?

@ZeeshanTamboli
Copy link
Member Author

ZeeshanTamboli commented Aug 30, 2023

is InternalStandardProps still useful or should we look into removing it?

I think it remains helpful for components aiming to eliminate conflicts between props and standard HTML attributes. For instance, in the Tooltip component, it prevents the title attribute of HTMLDivElement from conflicting with the title prop of Tooltip.

While we could directly extend div attributes without StandardProps like:

export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {

because style, ref, and className are already present in HTMLDivElement:

<div style={{ color: 'red' }} className="root" />

the second argument of StandardProps (Removals parameter) still appears beneficial.

Moreover, it also eliminates the extended component's classes type. For instance, in OutlinedInput, without StandardProps, the classes of the outlined input might be overridden by the Input base classes.


EDIT:

Moreover, it also eliminates the extended component's classes type. For instance, in OutlinedInput, without StandardProps, the classes of the outlined input might be overridden by the Input base classes.

Looks like this is not the case because the original classes type will override the extended ones (outlined input classes will override Input Base classes), but I still think it is useful to not define dual classes type.

Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into my question 😊

@ZeeshanTamboli ZeeshanTamboli merged commit ad99cf5 into mui:master Aug 31, 2023
5 checks passed
@ZeeshanTamboli ZeeshanTamboli deleted the fix-TabScrollButton-extended-type branch August 31, 2023 14:53
mnajdova pushed a commit to mnajdova/material-ui that referenced this pull request Sep 8, 2023
mnajdova pushed a commit to mnajdova/material-ui that referenced this pull request Sep 8, 2023
anon-phantom pushed a commit to anon-phantom/material-ui that referenced this pull request Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: tabs This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants