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
Fix zoom out mode toggling between pattern category selection #60225
Conversation
Previously, the useZoomOut check was within the category previews rather than the panel. This meant when the category changed, the zoom out check ran again. We only want the zoom out mode check to happen when the panel itself is mounted.
The useRef wasn't necessary, as it was running before the other useEffect that could set it to true.
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. |
Size Change: -34 B (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be interesting to know what changed that allows us the simplified hook. Great work 👏🏻
I was wondering this too. I tested it in the scenarios it was used, and it seems to work fine... I hope I'm not missing an edge case! |
…ess#60225) * Move useZoomout check up to PatternCategeryPreviewsPanel wrapper Previously, the useZoomOut check was within the category previews rather than the panel. This meant when the category changed, the zoom out check ran again. We only want the zoom out mode check to happen when the panel itself is mounted. * Simplify useZoomOut logic The useRef wasn't necessary, as it was running before the other useEffect that could set it to true.
…ess#60225) * Move useZoomout check up to PatternCategeryPreviewsPanel wrapper Previously, the useZoomOut check was within the category previews rather than the panel. This meant when the category changed, the zoom out check ran again. We only want the zoom out mode check to happen when the panel itself is mounted. * Simplify useZoomOut logic The useRef wasn't necessary, as it was running before the other useEffect that could set it to true.
What?
When viewing patterns on the site editor, the mode switches to zoom out mode. When selecting a new pattern category, it was incorrectly switching back to edit mode.
Why?
We only want to revert modes when the pattern panel collapses.
How?
Move the useZoomOut hook up a level to the panel wrapper. Also, refactor the useZoomOut mode hook for simplicity.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast