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

[TablePagination] Fix select variant not working #33974

Merged

Conversation

ZeeshanTamboli
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli commented Aug 18, 2022

Fixes #33894

Both the comments below are fixes of #33894.

@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work component: TablePagination The React component. labels Aug 18, 2022
@mui-bot
Copy link

mui-bot commented Aug 18, 2022

Details of bundle changes

Generated by 🚫 dangerJS against 9ef1aa8

@ZeeshanTamboli ZeeshanTamboli marked this pull request as draft August 18, 2022 10:06
@ZeeshanTamboli ZeeshanTamboli marked this pull request as ready for review August 18, 2022 11:01
@@ -199,7 +199,7 @@ const TablePagination = React.forwardRef(function TablePagination(inProps, ref)
{rowsPerPageOptions.length > 1 && (
<TablePaginationSelect
variant="standard"
input={<InputBase />}
{...(!SelectProps.variant && { input: <InputBase /> })}
Copy link
Member Author

Choose a reason for hiding this comment

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

InputBase should not always be rendered in TablePaginationSelect. If variant is passed through SelectProps prop, that particular variant input should be rendered instead.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder why the <InputBase /> is needed in the first place 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It's needed. Otherwise, <Input /> is rendered which is different visually. So InputBase should be rendered when no Select variant is provided.

And if variant standard is removed and input={<InputBase />} is kept, there is a slight difference in UI and argos detects changes.

Copy link
Member

Choose a reason for hiding this comment

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

Confirmed, the InputBase is needed.

@@ -114,7 +114,7 @@ const Select = React.forwardRef(function Select(inProps, ref) {
...(multiple && native && variant === 'outlined' ? { notched: true } : {}),
ref: inputComponentRef,
className: clsx(InputComponent.props.className, className),
variant,
...(!input && { variant }),
Copy link
Member Author

Choose a reason for hiding this comment

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

Do not propagate variant to root div in select input if custom input element is provided via Select's input prop. Basically, do not let variant be set like in the image below:

Capture

Copy link
Member

Choose a reason for hiding this comment

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

Nice, it does not introduce a regression if I do this:

<Select input={<OutlinedInput />}>

So, looks good.

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

The test looks good to me. Can you verify that the input={<InputBase />} is needed on the Select?

Copy link
Member

@siriwatknp siriwatknp 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 the hard work @ZeeshanTamboli

@@ -114,7 +114,7 @@ const Select = React.forwardRef(function Select(inProps, ref) {
...(multiple && native && variant === 'outlined' ? { notched: true } : {}),
ref: inputComponentRef,
className: clsx(InputComponent.props.className, className),
variant,
...(!input && { variant }),
Copy link
Member

Choose a reason for hiding this comment

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

@ZeeshanTamboli I think it deserves a comment. Can you add a comment that explain the consition and maybe link to the issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

@siriwatknp I added the comment.

@ZeeshanTamboli ZeeshanTamboli merged commit 97fd105 into mui:master Aug 25, 2022
@ZeeshanTamboli ZeeshanTamboli deleted the issue/33894-TablePagination-select branch August 25, 2022 08:15
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this pull request Nov 29, 2022
* add test cases

* apply Select variant if provided

* do not attach variant as an attribute to select root div

* update test

* test: parentNode -> parentElement

* fix visual regressions by allowing variant in inputProps

* add back variant standard

* add comment
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: TablePagination The React component.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TablePagination] select cannot be outlined
3 participants