From a953e3383e3c4c769ab7094a0cce36dea679af74 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Thu, 22 Aug 2024 02:40:14 +0200 Subject: [PATCH 1/3] [button] Fix loading button regression --- .../migration/upgrade-to-v6/upgrade-to-v6.md | 4 ---- .../mui-lab/src/LoadingButton/LoadingButton.js | 14 +++----------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/docs/data/material/migration/upgrade-to-v6/upgrade-to-v6.md b/docs/data/material/migration/upgrade-to-v6/upgrade-to-v6.md index a6efdaa62f5cd1..532a70fcc9ed0c 100644 --- a/docs/data/material/migration/upgrade-to-v6/upgrade-to-v6.md +++ b/docs/data/material/migration/upgrade-to-v6/upgrade-to-v6.md @@ -365,10 +365,6 @@ As the `ListItem` no longer supports these props, the class names related to the +listItemButtonClasses.selected ``` -### Loading Button - -In v6, the `children` prop passed to the Loading Button component is now wrapped in a `` tag to avoid [issues](https://github.com/mui/material-ui/issues/27853) when using tools to translate websites. - ### Rating Previously, due to a bug, the `aria-label` attribute was "null Stars" when no value was set in the Rating component. diff --git a/packages/mui-lab/src/LoadingButton/LoadingButton.js b/packages/mui-lab/src/LoadingButton/LoadingButton.js index 13d5a9aec21df1..f81b0951d9e880 100644 --- a/packages/mui-lab/src/LoadingButton/LoadingButton.js +++ b/packages/mui-lab/src/LoadingButton/LoadingButton.js @@ -241,17 +241,9 @@ const LoadingButton = React.forwardRef(function LoadingButton(inProps, ref) { classes={classes} ownerState={ownerState} > - {ownerState.loadingPosition === 'end' ? ( - {children} - ) : ( - loadingButtonLoadingIndicator - )} - - {ownerState.loadingPosition === 'end' ? ( - loadingButtonLoadingIndicator - ) : ( - {children} - )} + {ownerState.loadingPosition === 'end' ? null : loadingButtonLoadingIndicator} + {children} + {ownerState.loadingPosition === 'end' ? loadingButtonLoadingIndicator : null} ); }); From a9b73cc1dd69f6ae89d769683d43220e9f259100 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Fri, 23 Aug 2024 18:11:05 +0200 Subject: [PATCH 2/3] wip --- packages/mui-lab/src/LoadingButton/LoadingButton.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/mui-lab/src/LoadingButton/LoadingButton.js b/packages/mui-lab/src/LoadingButton/LoadingButton.js index f81b0951d9e880..cbc2ef2b1206a8 100644 --- a/packages/mui-lab/src/LoadingButton/LoadingButton.js +++ b/packages/mui-lab/src/LoadingButton/LoadingButton.js @@ -242,7 +242,9 @@ const LoadingButton = React.forwardRef(function LoadingButton(inProps, ref) { ownerState={ownerState} > {ownerState.loadingPosition === 'end' ? null : loadingButtonLoadingIndicator} - {children} + + {children} + {ownerState.loadingPosition === 'end' ? loadingButtonLoadingIndicator : null} ); From 8089a45755048a52b4e16c5628ce6314a3ba50ac Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 25 Aug 2024 19:49:02 +0200 Subject: [PATCH 3/3] try this --- packages/mui-lab/src/LoadingButton/LoadingButton.js | 6 ++---- packages/mui-utils/src/composeClasses/composeClasses.ts | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/mui-lab/src/LoadingButton/LoadingButton.js b/packages/mui-lab/src/LoadingButton/LoadingButton.js index cbc2ef2b1206a8..c3b17dacf5d9c7 100644 --- a/packages/mui-lab/src/LoadingButton/LoadingButton.js +++ b/packages/mui-lab/src/LoadingButton/LoadingButton.js @@ -229,7 +229,7 @@ const LoadingButton = React.forwardRef(function LoadingButton(inProps, ref) { {loadingIndicator} - ) : null; + ) : ; return ( {ownerState.loadingPosition === 'end' ? null : loadingButtonLoadingIndicator} - - {children} - + {children} {ownerState.loadingPosition === 'end' ? loadingButtonLoadingIndicator : null} ); diff --git a/packages/mui-utils/src/composeClasses/composeClasses.ts b/packages/mui-utils/src/composeClasses/composeClasses.ts index 2b8e91af5fb540..88fe25b1c3cc07 100644 --- a/packages/mui-utils/src/composeClasses/composeClasses.ts +++ b/packages/mui-utils/src/composeClasses/composeClasses.ts @@ -17,10 +17,10 @@ export default function composeClasses( for (let i = 0; i < slot.length; i += 1) { const value = slot[i]; if (value) { - buffer += getUtilityClass(value) + ' '; + buffer += (buffer === '' ? '' : ' ') + getUtilityClass(value); if (classes && classes[value]) { - buffer += classes[value] + ' '; + buffer += ' ' + classes[value]; } } }