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

[mui-material][button] Loading props added to button #42987

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

Gavin-10
Copy link

All functionality from loadingButton has been moved to Button in mui-material

closes #42684

Gavin McGuinness added 2 commits July 17, 2024 21:27
All functionality from loadingButton has been moved to Button in
mui-material
@Gavin-10 Gavin-10 marked this pull request as draft July 18, 2024 01:49
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 18, 2024
@mui-bot
Copy link

mui-bot commented Jul 18, 2024

Netlify deploy preview

@material-ui/core: parsed: +Infinity% , gzip: +Infinity%
@mui/joy: parsed: +Infinity% , gzip: +Infinity%
@material-ui/lab: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Autocomplete: parsed: +Infinity% , gzip: +Infinity%
@material-ui/unstyled: parsed: +Infinity% , gzip: +Infinity%
Autocomplete: parsed: +Infinity% , gzip: +Infinity%
TextField: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Select: parsed: +Infinity% , gzip: +Infinity%
SpeedDialAction: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Menu: parsed: +Infinity% , gzip: +Infinity%
Tooltip: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Tooltip: parsed: +Infinity% , gzip: +Infinity%
SwipeableDrawer: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Drawer: parsed: +Infinity% , gzip: +Infinity%
TabList: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/Snackbar: parsed: +Infinity% , gzip: +Infinity%
SpeedDial: parsed: +Infinity% , gzip: +Infinity%
Pagination: parsed: +Infinity% , gzip: +Infinity%
Alert: parsed: +Infinity% , gzip: +Infinity%
@mui/joy/MenuButton: parsed: +Infinity% , gzip: +Infinity%
and 271 more changes

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 5b429c6

Gavin McGuinness added 3 commits July 17, 2024 23:18
added Icon class to start and end icons, ran prettier, updated
loadingButton tests to test Button. LoadingButton tests not to be merged
@aarongarciah aarongarciah self-requested a review July 20, 2024 20:10
@ZeeshanTamboli ZeeshanTamboli added component: button This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Jul 21, 2024
Copy link
Member

@aarongarciah aarongarciah 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 working on this @Gavin-10! I did a first pass and left some inline comments. Apart from that, two more things:

  • The LoadingButton component implementation in mui-lab needs to be updated to just use the newly updated Button from mui-material. The Alert component in mui-lab is a good example of how to do this.
  • The Button usage docs must be updated:
    • The examples under the "Loading button" section must be updated to use Button and this section should be moved before the "File upload" section.
    • The "Experimental APIs" heading can be removed.
    • LoadingButton shouldn't be listed in the API section at the end of the page.

Let me know if you have any doubts or if you need help.

Comment on lines 691 to 702
/**
* Styles applied to the loadingIndicator element if `loadingPosition="center"`.
*/
loadingIndicatorCenter: PropTypes.string,
/**
* Styles applied to the loadingIndicator element if `loadingPosition="end"`.
*/
loadingIndicatorEnd: PropTypes.string,
/**
* Styles applied to the loadingIndicator element if `loadingPosition="start"`.
*/
loadingIndicatorStart: PropTypes.string,
Copy link
Member

Choose a reason for hiding this comment

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

These 3 props shouldn't be here. These are part of the classes prop which and they're already handled in buttonClasses.ts

Copy link
Member

Choose a reason for hiding this comment

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

This file shouldn't be commited.

pnpm-lock.yaml Outdated
Copy link
Member

Choose a reason for hiding this comment

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

No dependency changes should be included in this PR. Please undo changes in this file.

Comment on lines 404 to 405
const LoadingButtonLoadingIndicator = styled('span', {
name: 'MuiLoadingButton',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const LoadingButtonLoadingIndicator = styled('span', {
name: 'MuiLoadingButton',
const ButtonLoadingIndicator = styled('span', {
name: 'MuiButton',

size,
type,
variant,
};

const classes = useUtilityClasses(ownerState);

const loadingButtonLoadingIndicator = loading ? (
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const loadingButtonLoadingIndicator = loading ? (
const buttonLoadingIndicator = loading ? (

Comment on lines 657 to 660
/**
* Styles applied to the endIcon element if `loading={true}` and `loadingPosition="end"`.
*/
endIconLoadingEnd: PropTypes.string,
Copy link
Member

Choose a reason for hiding this comment

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

This prop shouldn't be here. These is part of the classes prop which is already handled in buttonClasses.ts

Comment on lines 721 to 724
/**
* Styles applied to the startIcon element if `loading={true}` and `loadingPosition="start"`.
*/
startIconLoadingStart: PropTypes.string,
Copy link
Member

Choose a reason for hiding this comment

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

This prop shouldn't be here. These is part of the classes prop which is already handled in buttonClasses.ts

size = 'medium',
startIcon: startIconProp,
type,
variant = 'text',
...other
} = props;

const id = useId(idProp);
const loadingIndicator = loadingIndicatorProp ?? (
<CircularProgress aria-labelledby={id} aria-label={`${children}`} color="inherit" size={16} />
Copy link
Member

Choose a reason for hiding this comment

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

aria-label={${children}} will produce be equal to "[object Object]" if a React element is passed as children. Let's use the exact same implementation that exists in LoadingButton for now. See example: https://codesandbox.io/p/sandbox/brave-panini-xm3vsv?file=/src/App.js:4,16

Suggested change
<CircularProgress aria-labelledby={id} aria-label={`${children}`} color="inherit" size={16} />
<CircularProgress aria-labelledby={id} color="inherit" size={16} />

Copy link
Member

Choose a reason for hiding this comment

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

All of LoadingButton tests should be moved to the Button component in mui-material. This file shouldn't exist once the refactor is done.

@aarongarciah aarongarciah self-assigned this Aug 21, 2024
Button.js variable names changed, extra classes deleted,
loading button tests moved to button.test.js, pnpm-lock restored,
last-run.json removed (hopefully)
@Gavin-10
Copy link
Author

Thank you so much @aarongarciah for the review! I have implemented all the suggested changes and almost ready to push again. I just have two quick questions. To remove the loading button from the API list do I need to just delete the .json and .js file from the API folder or are there more steps I need to do? Last, all of those extra props were generated when I ran pnpm proptypes and I'm just wondering why they need to be removed so I can have a better understanding for future contributions? Thank you so much.

@aarongarciah
Copy link
Member

To remove the loading button from the API list do I need to just delete the .json and .js file from the API folder or are there more steps I need to do?

To remove LoadingButton from the API list, you just need to remove LoadingButton from the front matter in the corresponding docs markdown file. See

components: Button, IconButton, ButtonBase, LoadingButton

Last, all of those extra props were generated when I ran pnpm proptypes

I should have left the comment in the .d.ts file instead of the .js file. pnpm proptypes generates proptypes based on the types defined in the .d.ts file. So if you remove the unwanted props from the .d.ts file, running pnpm proptypes again will remove the proptypes from the .js file.

Every time you make a proptypes change (add, remove, or modify comments) you'll need to run pnpm docs:api so the corresponding .json files consumed by the docs are updated.

Another common script is pnpm docs:typescript, which we run after modifying any demo file: we work on .tsx files and this script generates the corresponding .js file.

Take a look at https://github.com/mui/material-ui/blob/next/CONTRIBUTING.md#sending-a-pull-request if you have doubts and feel free to ping me anytime you get stuck.

Happy coding!

@Gavin-10 Gavin-10 marked this pull request as ready for review August 25, 2024 20:52
@Gavin-10
Copy link
Author

Everything should be about wrapped up now. I fixed the dependency issues and some minor styling issues with child elements. The test_unit and test_browser tests failing is expected and caused by the CircularProgress not having accessibility labels. I however do not know why test_e2e_website is failing. Once that is resolved though, I believe everything should be ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: button This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[material-ui][Button] Button doesn't have the loading props
4 participants