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

[charts] browser reduce motion does not disable the initial animation in production #13477

Closed
alexfauquette opened this issue Jun 14, 2024 · 13 comments · Fixed by #14417
Closed
Labels
accessibility a11y bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module!

Comments

@alexfauquette
Copy link
Member

alexfauquette commented Jun 14, 2024

Steps to reproduce

See mui/material-ui#42537 (comment)

Current behavior

No response

Expected behavior

No response

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: a11y animation charts

@alexfauquette alexfauquette added status: waiting for maintainer These issues haven't been looked at yet by a maintainer bug 🐛 Something doesn't work accessibility a11y component: charts This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 14, 2024
@JCQuintas
Copy link
Member

Btw, I believe this happens because the Global change is triggered in about the same render step or after the animation starts. If we skipAnimation statically, the issue disappears.

// docs/pages/_app.js
import { Globals } from '@react-spring/web';

Globals.assign({
  skipAnimation: true,
});

@Janpot
Copy link
Member

Janpot commented Sep 6, 2024

Btw, I believe this happens because the Global change is triggered in about the same render step or after the animation starts. If we skipAnimation statically, the issue disappears.

I was taking another look at the flaky regression test in core and when I set CPU throttling to 6x, I'm still seeing some sort of initial animation happening on docs-getting-started-templates-dashboard-components/MainGrid:

Screen.Recording.2024-09-06.at.05.12.49.mov

Even with global animations turned off it seems to be rendering something narrower on the initial render. Just saying because these tests do

Globals.assign({
  skipAnimation: true,
});

Maybe this is a separate issue?

@alexfauquette
Copy link
Member Author

This motion does not correspond to one of our animations. It's much closer to what happened when the responsive container resize 🤔

image
image

@Janpot
Copy link
Member

Janpot commented Sep 6, 2024

This motion does not correspond to one of our animations. It's much closer to what happened when the responsive container resize 🤔

By "responsive container" you still mean "of the chart", right? Because the direct parent element does not resize.

@JCQuintas
Copy link
Member

Would it be possible that it is rendered in a size on ssr and then hydrated into another size? 🤔

It does indeed look like the chart just changed size. Are you able to check the svg properties when this is happening?

@Janpot
Copy link
Member

Janpot commented Sep 6, 2024

It's the core regression testing fixture. It's not SSRed, it's rendered in a nested React root created in an effect. To reproduce:

  1. On the core repository
  2. Run pnpm test:regressions:dev
  3. Set CPU trhottling in the browser to 6x
  4. visit http://localhost:5001/docs-getting-started-templates-dashboard-components/MainGrid.

Are you able to check the svg properties when this is happening?

In the devtool elements panel you mean? No, not really, it always resets on reload.

@JCQuintas
Copy link
Member

Any specific browser? I didn't see this behaviour on chrome, tested both 6x and 20x

@Janpot
Copy link
Member

Janpot commented Sep 6, 2024

That was on Chrome. This is firefox:

Screen.Recording.2024-09-06.at.17.09.51.mov

Seeing the same on Safari, Edge and mobile chrome. But only when running locally, latest master. Not seeing it on the deployed version. Maybe it's something poisoning the build locally 🤔

@JCQuintas
Copy link
Member

Oddly enough, was seeing it happening when the CPU is not slowed down, but not after I open the devtools. Turns out the devtools made it withing the width range where the issue doesn't appear.

Sweet spot is between ~912 - ~1590 where no shuflling happens

I would assume this specific issue is due to some layout changes after css/js is loaded?

@Janpot
Copy link
Member

Janpot commented Sep 8, 2024

I reduced the test fixture down to:

import * as React from 'react';
import * as ReactDOMClient from 'react-dom/client';
import { Globals } from '@react-spring/web';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid2';
import { SparkLineChart } from '@mui/x-charts/SparkLineChart';

Globals.assign({
  skipAnimation: true,
});

function StatCard() {
  return (
    <Grid size={6} sx={{ height: 50 }}>
      <SparkLineChart data={[1640, 220]} />
    </Grid>
  );
}

function App() {
  return (
    <Box sx={{ display: 'inline-block' }}>
      <Grid container spacing={2}>
        <StatCard />
        <StatCard />
        <StatCard />
      </Grid>
    </Box>
  );
}

const container = document.getElementById('react-root');
const children = <App />;
const reactRoot = ReactDOMClient.createRoot(container);
reactRoot.render(children);
Screen.Recording.2024-09-08.at.12.39.42.mov

It looks like there is some interaction going on between the top level inline-block in the test viewer, the Grid2 and the SparkLineChart.

codesandbox behaves differently though.

Screenshot 2024-09-08 at 12 41 39

@JCQuintas
Copy link
Member

@Janpot the issue here seems to be that the container doesn't have a proper width, which means the children has to "grow until they fit" into the container.

One alternative would be to change the component that has the display: 'inline-block' to have a width as well. <Box sx={{ display: 'inline-block', width: '100%' }}>

I've created #14553 which should fix the issue in most common cases if the proper solution above is not possible.

@Janpot
Copy link
Member

Janpot commented Sep 9, 2024

it's possible but it updates all the screenshots mui/material-ui#43656

Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants