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

[LoadingButton] Fix variant default prop not inheriting from MuiButton theme slot #30126

Conversation

ZeeshanTamboli
Copy link
Member

Fixes #29740

@ZeeshanTamboli ZeeshanTamboli added component: LoadingButton The React component. regression A bug, but worse labels Dec 9, 2021
@mui-pr-bot
Copy link

mui-pr-bot commented Dec 9, 2021

Details of bundle changes

Generated by 🚫 dangerJS against 60a6d34

@ZeeshanTamboli ZeeshanTamboli marked this pull request as ready for review December 9, 2021 06:00
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.

Nice, thanks!

@@ -106,7 +106,7 @@ const LoadingButtonLoadingIndicator = styled('div', {
left: 14,
}),
...(ownerState.loadingPosition === 'start' &&
ownerState.variant === 'text' && {
(!ownerState.variant || ownerState.variant === 'text') && {
Copy link
Member

@oliviertassinari oliviertassinari Dec 9, 2021

Choose a reason for hiding this comment

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

I'm might be missing something but this change looks KO. If the default Button variant is outlined, then the style of the LoadingButton should also have the outlined version, not the text one.

Going on step deeper, I challenged if it's a regression or the correct behavior #29740 (comment). In any case, my feedback is that I think we should either do nothing or go all the way down. Currently we restore the previous behavior which was lying to developers.

Copy link
Member

Choose a reason for hiding this comment

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

@oliviertassinari I agree, and I was personally the one that did the change on the previous PR. The problem is that it is a breaking change, and we released it in a minor, so people complained. We can revisit this again in v6, but in my opinion, it is better to let this change land now. Does this make sense?

Copy link
Member

@oliviertassinari oliviertassinari Dec 9, 2021

Choose a reason for hiding this comment

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

Interesting, I see two topics:

  1. How should we handle bug fixes that are breaking changes? Personally, I think that we can emphasize on the bug fix part. My hypotheses is that for any bug fix, there are people relying on the wrong behavior, we still need to be able to fix bugs.
  2. Let's say we are working on v6 right now (we are not, but to simplify the problem) what would be the "right" behavior? (I'm asking because it's not clear to me)

Copy link
Member

Choose a reason for hiding this comment

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

How should we handle bug fixes that are breaking changes? Personally, I think that we can emphasize on the bug fix part. My hypothesis is that for any bug fix, there are people relying on the wrong behavior, we still need to be able to fix bugs.

Agree, the only problem I see with this scenario is that, no one complained (or saw as a bug the behavior that we had before), so if we are changing it, we are kind of fixing a non-existing bug, or at least a bug people are not aware of. In any way, if we actually do this, we should document better in the changelog the fact that the expected behavior changed for the component, so that people can catch it earlier.

Copy link
Member

Choose a reason for hiding this comment

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

Let's say we are working on v6 right now (we are not, but to simplify the problem) what would be the "right" behavior? (I'm asking because it's not clear to me)

I would add a default value or the variant inside the LoadingButton.

Copy link
Member

Choose a reason for hiding this comment

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

Should theme.components.MuiButton.defaultProps.variant also impact the default variant of MuiLoadingButton or not

To be honest I am not sure. From user's perspective it should either always impact the prop in the LoadingButton or not. At this moment, it impacts only the props that do not have a default value in the LoadingButton. This is not intuitive.

On one hand, impacting the default props for the LoadingButton is good, as the component is kind of an extension of the Button. But on the other hand, it looks like a hidden side effect. I think we should create an RFC and decide on this generally for all components and implement it consistently for v6.

Copy link
Member

Choose a reason for hiding this comment

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

@mnajdova, @oliviertassinari, just to be clear: is the conclusion here to merge this PR and think of a better solution for v6?

Copy link
Member

Choose a reason for hiding this comment

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

@michaldudak sorry yes. I think we should proceed with the PR as it reverts a breaking change that we introduced. I am adding this discussion to our v6 project :)

Copy link
Member

@oliviertassinari oliviertassinari Dec 23, 2021

Choose a reason for hiding this comment

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

To be honest I am not sure. From user's perspective it should either always impact the prop in the LoadingButton or not. At this moment, it impacts only the props that do not have a default value in the LoadingButton. This is not intuitive.
On one hand, impacting the default props for the LoadingButton is good, as the component is kind of an extension of the Button. But on the other hand, it looks like a hidden side effect. I think we should create an RFC and decide on this generally for all components and implement it consistently for v6.

@mnajdova Ok, in this case, I propose we avoid surprises: theme.components.MuiXXX.defaultProps <==> one component. So no side effects on other components.

Now, in practice, what does it mean?

So personally, I would suggest we close #30126 and #29740. We are good. Is it a breaking change? I would argue that it was partially working before (only the prop inheritance, not the host style), and we didn't intend to have it work this way, nor was it documented or tested => so I think that it's not a breaking change.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds fair, I left a comment on the issue, I am closing this PR too. @ZeeshanTamboli thanks for the effort on this one.

@oliviertassinari oliviertassinari added the component: button This is the name of the generic UI component, not the React module! label Dec 9, 2021
@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Jan 8, 2022
@mnajdova mnajdova closed this Jan 13, 2022
@danderson00
Copy link

This is an issue in version 5.8.7, perhaps a regression?

@ZeeshanTamboli ZeeshanTamboli deleted the issue/29740-loadingButton-defaultProps branch August 16, 2023 06:52
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: button This is the name of the generic UI component, not the React module! component: LoadingButton The React component. regression A bug, but worse
Projects
None yet
6 participants