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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lab][LoadingButton] Apply wrapping element to prevent React crash on Google page translation #35198

Merged
merged 5 commits into from
Jun 14, 2024

Conversation

BartJanvanAssen
Copy link
Contributor

@BartJanvanAssen BartJanvanAssen commented Nov 18, 2022

Hey folks 馃憢
I ran into this issue where some of our customers on our site were trapped by this react crashing loading button. I wanted to to invest some time to get it out of the package.

Use case summary:

Using the LoadingButton while have Google translation (chrome feature) active on your site.
Problem: Google modifies the button contents and React can't figure out its bindings anymore. Causes crash 馃挜

How to reproduce:

https://codesandbox.io/s/dry-water-eig2e7?file=/demo.tsx

Steps:

  • Open sandbox in external browser
  • Use google chrome's translate feature (see screenshot)
  • Click the loading button
  • Notice crash 馃挜
    image

Why this solution?

I've implemented one of the suggestion in the issue, tested it locally and it seemed to work out perfectly.

馃槂 This is my first contribution to MUI, so if I need to change something, let me know.

Closes #27853

@zannager zannager added the component: button This is the name of the generic UI component, not the React module! label Nov 21, 2022
@BartJanvanAssen
Copy link
Contributor Author

@gzrae @eps1lon do you want to check this out relating #27853 ?

@michaldudak michaldudak added this to the v6 milestone Jan 3, 2023
@michaldudak michaldudak added the on hold There is a blocker, we need to wait label Jan 3, 2023
@michaldudak michaldudak removed their request for review January 3, 2023 19:17
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

I wonder if we even need to add wrappers, maybe changing the conditioning logic could solve this. An option mentioned in #27853 (comment).

@michaldudak why add the "on hold" label? This component is unstable.

packages/mui-lab/src/LoadingButton/LoadingButton.js Outdated Show resolved Hide resolved
@oliviertassinari oliviertassinari removed this from the v6 milestone Jan 28, 2023
@@ -29,6 +29,10 @@ const useUtilityClasses = (ownerState) => {
};
};

const contentDivStyles = {
display: 'contents'
Copy link
Member

Choose a reason for hiding this comment

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

Interesting trick, it seems to have tons of limitations https://caniuse.com/css-display-contents but maybe it's OK in this context.

Copy link
Member

Choose a reason for hiding this comment

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

Should be tested with assistive technology. I think VoiceOver had big problems with this. I think it's safer to not use display: contents in the forseeable future.

Copy link
Member

Choose a reason for hiding this comment

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

I'm still unsure if display: contents can be trusted seeing all of the literature written around how problematic it is. I've removed it for now, but if we feel strong about its benefits we can spend some time testing on different combinations of screen readers and browsers. See this other comment: #35198 (comment)

packages/mui-lab/src/LoadingButton/LoadingButton.js Outdated Show resolved Hide resolved
@michaldudak
Copy link
Member

why add the "on hold" label? This component is unstable.

See #27853 (comment)

Yes, it's unstable, but if we don't have to introduce breaking changes, especially if the fix is possible in userland, should we?

@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 29, 2023

Yes, it's unstable, but if we don't have to introduce breaking changes, especially if the fix is possible in userland, should we?

@michaldudak This confuses me. It sounds like we either: 1. don't want to fix this bug since we don't think it's important enough for a BC or 2. we should make this component stable since we don't want to introduce BCs. I don't understand the logic for waiting v6.

@michaldudak
Copy link
Member

My reasoning is: the LoadingButton component, while unstable, has been around for a while, and likely is used in several projects. The workaround in userland is very simple, so working on a fix on our side immediately isn't crucial.
Now, it's not a hill I want to die on, so if you want to have it fixed sooner, be my guest.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 31, 2023

@michaldudak OK, I propose that we don't tie the fix to a specific major version then. It sounds like we are more on case 1. (we don't think it's important enough). So effectivement, we are waiting for the pain to grow, more people to complain about it, to feel that working on it is the lowest opportunity cost. Maybe we will fix it in v5.34.0 or maybe in v7.0.0 or maybe never.

@pvinicius
Copy link

pvinicius commented Mar 1, 2023

@michaldudak OK, I propose that we don't tie the fix to a specific major version then. It sounds like we are more on case 1. (we don't think it's important enough). So effectivement, we are waiting for the pain to grow, more people to complain about it, to feel that working on it is the lowest opportunity cost. Maybe we will fix it in v5.34.0 or maybe in v7.0.0 or maybe never.

that issue was responsible for a bug in my current sprint :D
but I've seen the official doc and I fixed it, thanks

@aarongarciah aarongarciah added package: lab Specific to @mui/lab component: LoadingButton The React component. and removed component: button This is the name of the generic UI component, not the React module! on hold There is a blocker, we need to wait labels Jun 5, 2024
@aarongarciah aarongarciah changed the title [LoadingButton] Apply wrapping div to prevent react crash on Google page translation [lab][LoadingButton] Apply wrapping element to prevent React crash on Google page translation Jun 6, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 6, 2024
@aarongarciah aarongarciah changed the base branch from master to next June 6, 2024 17:00
@aarongarciah aarongarciah self-assigned this Jun 6, 2024
@mui-bot
Copy link

mui-bot commented Jun 6, 2024

@aarongarciah
Copy link
Member

aarongarciah commented Jun 6, 2024

Hey @BartJanvanAssen! I'm picking picking this up to land it for v6. I introduced two changes in 9b6e3a1:

  1. Use a <span> instead of a <div> to wrap children.
  2. Remove display: contents.

Regarding number 2, display: contents suffered from deep accessibility issues for years, the most important one causing elements with the property applied to be removed from the accessibility tree. Most of these issues have been solved over the years, but it's still unclear if it's 100% reliable, especially on Safari. I'm wary of using this property if we're not 100% sure about it'll have the expected behavior. If we feel strong about its benefits we can spend some time testing on different combinations of screen readers and browsers. Let me know your thoughts. Some literature on the topic:

@aarongarciah aarongarciah reopened this Jun 6, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 6, 2024
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

@aarongarciah may I ask you to add a section explaining this change in the migration guide, as it might be a breaking change for some users 馃槉

@aarongarciah
Copy link
Member

aarongarciah commented Jun 13, 2024

@DiegoAndai entry added to the migration guide 883ace8

@DiegoAndai
Copy link
Member

entry added to the migration guide 883ace8

Thanks, may I ask you to move it to the v5 breaking changes: https://github.com/mui/material-ui/blob/next/docs/data/material/migration/migration-v5/migration-v5.md#breaking-changes

@aarongarciah
Copy link
Member

@DiegoAndai done

Copy link
Member

@DiegoAndai DiegoAndai 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 @aarongarciah! Here's the before and after testing that the issue is fixed

Before

Sandbox

Screen.Recording.2024-06-14.at.11.41.24.mov

After

Sandbox

Screen.Recording.2024-06-14.at.11.42.55.mov

@aarongarciah aarongarciah merged commit b51fd5d into mui:next Jun 14, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[material-ui][LoadingButton] Crashes React when Chrome has Translated the Page
9 participants