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][base] Improve actions type in slotProps #36458

Merged
merged 9 commits into from
Mar 28, 2023

Conversation

sai6855
Copy link
Contributor

@sai6855 sai6855 commented Mar 7, 2023

before:
Screenshot 2023-03-07 at 6 27 44 PM

after :
Screenshot 2023-03-07 at 6 27 34 PM

codesandbox after: https://codesandbox.io/s/k4s8qy?file=/demo.tsx

@mui-bot
Copy link

mui-bot commented Mar 7, 2023

Netlify deploy preview

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

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against 1190713

@@ -67,5 +67,11 @@ const styledTablePagination = (
toolbar: Toolbar,
spacer: Spacer,
}}
slotProps={{
Copy link
Contributor Author

@sai6855 sai6855 Mar 7, 2023

Choose a reason for hiding this comment

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

Test , for the change

@zannager zannager added package: base-ui Specific to @mui/base component: TablePagination The React component. labels Mar 8, 2023
@zannager zannager requested a review from siriwatknp March 8, 2023 07:01
@hbjORbj hbjORbj changed the title [TablePagination][Base] Improve actions type in slotProps [TablePagination][base] Improve actions type in slotProps Mar 8, 2023
Copy link
Member

@hbjORbj hbjORbj left a comment

Choose a reason for hiding this comment

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

LGTM!

@sai6855 sai6855 mentioned this pull request Mar 13, 2023
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

This change makes a lot of sense to me. We shouldn't require people to add overrides to TablePaginationUnstyledActionsSlotPropsOverrides if the default unstyled component is used. cc @michaldudak what do you think about this? If we agree on this, we would probably need to udpate some other slot types as well.

@@ -12,7 +13,8 @@ export interface LabelDisplayedRowsArgs {
export type ItemAriaLabelType = 'first' | 'last' | 'next' | 'previous';

export interface TablePaginationUnstyledRootSlotPropsOverrides {}
export interface TablePaginationUnstyledActionsSlotPropsOverrides {}
export interface TablePaginationUnstyledActionsSlotPropsOverrides
Copy link
Member

@michaldudak michaldudak Mar 13, 2023

Choose a reason for hiding this comment

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

The Overrides interface should be empty (by convention). If you'd like to specify the type of the slotProps field, define slotProps.actions as actions?: SlotComponentProps<typeof TablePaginationActionsUnstyled, TablePaginationUnstyledActionsSlotPropsOverrides, TablePaginationUnstyledOwnerState>, similarly to how SelectUnstyled defines its slotProps.popper.

The first generic parameter to SlotComponentProps defines the type of a component whose props will be accessible to provide to a slot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michaldudak Ah okay wasn't aware of convention. I've applied your suggestion in this commit bb5aa2f

@michaldudak
Copy link
Member

Could you please merge in the latest master to ensure the tests are run on the current codebase?

@@ -1,6 +1,8 @@
import * as React from 'react';
import { OverrideProps } from '@mui/types';
import { SlotComponentProps } from '../utils';
import TablePaginationActionsUnstyled from './TablePaginationActionsUnstyled';
import * as CommonTypes from './common.types';
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't import { ItemAriaLabelType } from './common.types' work? It would be more inline with our other imports.

Copy link
Contributor Author

@sai6855 sai6855 Mar 14, 2023

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't have to be, does it?
If you import { ItemAriaLabelType } from './common.types'; line 14 can be deleted. Or am I missing something?

Copy link
Contributor Author

@sai6855 sai6855 Mar 14, 2023

Choose a reason for hiding this comment

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

Wouldn't it be breaking change if export ItemAriaLabelType is deleted from TablePaginationUnstyled.types.ts?
cc @michaldudak

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved in this commit 2494ff7

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 18, 2023
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 18, 2023
Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

Looks good now. Thanks for working on this!

@sai6855 sai6855 mentioned this pull request Mar 28, 2023
1 task
@mj12albert mj12albert merged commit cc98505 into mui:master Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: TablePagination The React component. package: base-ui Specific to @mui/base typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants