material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

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

Open Gavin-10 opened this issue 1 year ago • 5 comments

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

closes #42684

Gavin-10 avatar Jul 18 '24 01:07 Gavin-10

Netlify deploy preview

IconButton: parsed: +4.61% , gzip: +3.47% Alert: parsed: +3.99% , gzip: +3.08% Autocomplete: parsed: +2.44% , gzip: +1.83% @material-ui/core: parsed: +0.58% , gzip: +0.40% LoadingButton: parsed: -1.09% :heart_eyes:, gzip: -0.46% :heart_eyes: @material-ui/lab: parsed: -0.14% :heart_eyes:, gzip: +0.02%

Bundle size report

Details of bundle changes (Toolpad) Details of bundle changes

Generated by :no_entry_sign: dangerJS against 579e3313e85aeff2b913149ab1b843ffb37082ba

mui-bot avatar Jul 18 '24 01:07 mui-bot

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.

Gavin-10 avatar Aug 22 '24 23:08 Gavin-10

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 https://github.com/mui/material-ui/blob/e52c45ee0330678187e8826ab95f7ac383ed006c/docs/data/material/components/buttons/buttons.md?plain=1#L4

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!

aarongarciah avatar Aug 23 '24 08:08 aarongarciah

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.

Gavin-10 avatar Aug 28 '24 03:08 Gavin-10

@Gavin-10 there are some conflicts that need to be solved.

aarongarciah avatar Sep 12 '24 15:09 aarongarciah

@aarongarciah I can continue with this PR since it seems inactive. It will also resolve #31235.

ZeeshanTamboli avatar Oct 30 '24 10:10 ZeeshanTamboli

@ZeeshanTamboli go ahead! Thanks

aarongarciah avatar Oct 30 '24 10:10 aarongarciah

@aarongarciah This is ready for further review. The Argos CI is failing because the 'Fetch data' button was removed from the demo.

ZeeshanTamboli avatar Nov 01 '24 05:11 ZeeshanTamboli

@ZeeshanTamboli @aarongarciah I am able to remove the label that wraps the children and it looks fine to me. Would you mind do a final check if I missed anything?

Before: https://codesandbox.io/p/sandbox/nice-volhard-pw7gqg?file=%2Fsrc%2FDemo.tsx%3A12%2C18

After: https://codesandbox.io/p/sandbox/serene-bassi-js4z6v?file=%2Fsrc%2FDemo.tsx%3A22%2C15

Both produce the same visual apprearance.

image

siriwatknp avatar Nov 06 '24 07:11 siriwatknp

@siriwatknp what about this? Is it not a problem? https://github.com/mui/material-ui/pull/35198

aarongarciah avatar Nov 06 '24 08:11 aarongarciah

@siriwatknp what about this? Is it not a problem? #35198

I pushed an alternative

@siriwatknp what about this? Is it not a problem? #35198

I am able to fix this problem without wrapping an extra span. However, the loading indicator wrapper has to always exist (with display: none when not loading).

I think this solution is better than wrapping with span because it won't cause layout shift.

https://github.com/user-attachments/assets/368f0584-8eae-48dd-a222-ad0b37e94353

siriwatknp avatar Nov 07 '24 04:11 siriwatknp

Confirmed google translate doesn't break: https://codesandbox.io/p/sandbox/material-ui-cra-ts-forked-fdkkn7.

ZeeshanTamboli avatar Nov 09 '24 07:11 ZeeshanTamboli

@aarongarciah @siriwatknp I made these changes:

  • Removed the button label slot and class: https://github.com/mui/material-ui/pull/42987/commits/a354fd511c8b33ab549d99f4eefd4dc5f84b784a
  • Updated the warning text: https://github.com/mui/material-ui/pull/42987/commits/c24da44e758fb821487b0fed76eae6826e898549
  • Updated the migration guide: https://deploy-preview-42987--material-ui.netlify.app/material-ui/migration/upgrade-to-v6/#button-with-loading-state

I guess we just need to check if this PR also resolves #43436.

ZeeshanTamboli avatar Nov 09 '24 10:11 ZeeshanTamboli

I guess we just need to check if this PR also resolves #43436.

That's about IconButton, I think it's better to add loading to IconButton in this PR. Otherwise, it will be a regression of https://github.com/mui/material-ui/pull/43436.

siriwatknp avatar Nov 13 '24 09:11 siriwatknp

@ZeeshanTamboli pushed the loading prop for IconButton. Here is the demo https://deploy-preview-42987--material-ui.netlify.app/material-ui/react-button/#loading-with-badge

siriwatknp avatar Nov 13 '24 12:11 siriwatknp

Can we add tests for IconButton with loading state?

Added, thanks.

siriwatknp avatar Nov 14 '24 07:11 siriwatknp

PR was reverted in #44478.

oliviertassinari avatar Nov 26 '24 13:11 oliviertassinari