-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Controlled useZoomOut #66574
Controlled useZoomOut #66574
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@draganescu @richtabor I'd be interested in your thoughts on this approach vs #66381. Please try them both out and see which one feels like a nicer UX. |
Size Change: +86 B (0%) Total Size: 1.83 MB
ℹ️ View Unchanged
|
Flaky tests detected in 9571222. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11581302494
|
I think this PR works better in terms of expected outcome. The idea is this:
This PR achieves this for the inserter:
However, this does not work for the global styles -> browse styles: here if the user starts in default zoom view, and opens browse styles, we programatically enter zoom out view, but exiting browse styles does not revert to default zoom view. |
It looks like the global styles UI is mounted twice for some reason, so when it mounts, it runs I don't think it's caused by react dev mode, but maybe. I'm not sure if the bug is the component being mounted twice or if the useZoomOut implementation for the global styles sidebar should change. |
The problem of both this and #66381 is that they show the bug in global styles. I understand that neither cause the bug, but ... it'd be great if the one we merge also fixes the bug:
|
Co-authored-by: Dave Smith <[email protected]>
Co-authored-by: Dave Smith <[email protected]>
…e via blocks tab and back to zoom out tab
This modifies the idea of the useZoomOut state to allow for a controlled mode. If the user begins in zoom out or manually toggles the zoom level, then we assume they are a user who understands the zoom levels and doesn't need this toggled for them. If they begin from a non-zoomed state, we can zoom in when they reach the patterns tab and remove the zoom level when they exit the inserter. If they use the zoom button when the inserter is open, this also removes the control mode, as they understand how to enter and exit zoom out. The idea here is: - it is jarring to have the zoom level automatically change for you, so default to not changing it unless it seems like the user doesn't know how to use the zoom button. - have a smart default, but allow overrides
9571222
to
f0a717f
Compare
Closing in favor of #67591 |
What?
Only control zoom level in useZoomOut if starting from non-zoomed state.
Fixes #66328
Why?
This modifies the idea of the useZoomOut state to allow for a controlled mode. If the user begins in zoom out or manually toggles the zoom level, then we assume they are a user who understands the zoom levels and doesn't need this toggled for them. If they begin from a non-zoomed state, we can zoom in when they reach the patterns tab and remove the zoom level when they exit the inserter. If they use the zoom button when the inserter is open, this also removes the control mode, as they understand how to enter and exit zoom out.
The idea here is:
How?
Add controlZoomLevel ref to track if we should be controlling the zoom level for the user or not.
Testing Instructions
Starting from Zoom Out
Starting from Zoom In (zoom level === 100)
Starting from Zoom In (zoom level === 100) and manually toggle zoom mode via header (exit control mode)
Testing Instructions for Keyboard
Screenshots or screencast