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

[docs] Fix layout jump on first mistake #35215

Merged

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Nov 21, 2022

React runner has a cache to render an element in the case of an exception. However, if the very first update he's given is broken, a layout shift breaks the DX. I got annoyed by this a couple of times. It's frequent for the first edit to make the code broken.

Before

Screen.Recording.2022-11-21.at.01.14.18.mov

https://mui.com/material-ui/react-alert/#basic-alerts

Instead, what we can do is render the correct version as soon as the developer starts to interact with the demo. The other added benefit is that it makes it easier to spot broken react runner runtimes.

After

Screen.Recording.2022-11-21.at.01.16.23.mov

https://deploy-preview-35215--material-ui.netlify.app/material-ui/react-alert/#basic-alerts


I almost wonder if it would make sense to scroll-lock the editor. Even with this change, it's frequent to make changes that are disorienting when focusing on the code editor. The downside of a scroll lock would be that when we actually want to focus on the demo, it might feel strange to see it expand from the top, and not the bottom.

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation bug 🐛 Something doesn't work scope: docs-infra Specific to the docs-infra product labels Nov 21, 2022
@mui-bot
Copy link

mui-bot commented Nov 21, 2022

Messages
📖 Netlify deploy preview: https://deploy-preview-35215--material-ui.netlify.app/

No bundle size changes

Generated by 🚫 dangerJS against cb94680

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.

Looks much better

I almost wonder if it would make sense to scroll-lock the editor. Even with this change, it's frequent to make changes that are disorienting when focusing on the code editor.

+1 for locking the scroll.

Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@oliviertassinari oliviertassinari enabled auto-merge (squash) November 23, 2022 14:08
@oliviertassinari oliviertassinari merged commit 686f1fe into mui:master Nov 23, 2022
@oliviertassinari oliviertassinari deleted the live-edit-fix-layout-jump branch November 23, 2022 14:35
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this pull request Nov 29, 2022
Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
feliperli pushed a commit to jesrodri/material-ui that referenced this pull request Dec 6, 2022
Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work docs Improvements or additions to the documentation scope: docs-infra Specific to the docs-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants