-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 useZoomOut inserter behavior #67591
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. |
Size Change: +71 B (0%) Total Size: 1.83 MB
ℹ️ View Unchanged
|
Experience wise, this feels nice. It stays zoomed out when expected to, and zooms back in when appropriate. CleanShot.2024-12-05.at.11.59.23.mp4 |
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.
This feels nice! You don't end up in unexpected scenarios where zoom out is auto re-engaged.
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.
Thank you, @jeryj!
The fix looks good to me ✅ I just left a couple of notes regarding e2e tests.
P.S. Rebasing should fix the failing e2e test.
1b32f30
to
dd36078
Compare
dd36078
to
bb69b54
Compare
bb69b54
to
3318d08
Compare
The same e2e test keeps failing even after rebasing and trying several times to rerun it. It passes locally. Not sure what's going on with it. It doesn't seem related to this PR. |
This test kept failing for me, and I isolated it to if a test before it had run await admin.visitSiteEditor(), then the preload test would fail because the user had previously visited the site editor. By resetting preferences before the test runs, it allows a cleaner enviroment and the test has consistent results.
@@ -6,6 +6,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | |||
test.describe( 'Preload', () => { | |||
test.beforeAll( async ( { requestUtils } ) => { | |||
await requestUtils.activateTheme( 'emptytheme' ); | |||
await requestUtils.resetPreferences(); |
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.
This should really be in a different PR, but I wanted to see if adding this would fix the e2e issue I'm running into. More context in the PR that implemented the Preload test.
tl;dr: The Preload test will have different results depending on what runs before it, and this should help normalize it. I just happened to run into the issue by having my test run on the same shard.
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 did work -- I would have liked this fix a different PR but it auto-merged once the tests passed.
Fixes #66328
What?
Track if the useZoomOut hook changed the zoom level for the user. If we never changed it, don't change the zoom level on unmount.
Request from @richtabor: If we did change zoom level via the
useZoomOut
hook (controlled mode) alwaysresetZoomLevel()
on unmount.Why?
Fixes a bug where zoom out was engaged/disengaged incorrectly on unmount.
How?
Adds a
controlZoomLevelRef
that tracks if we ever changed the zoom level for the user. When unmounting, if we changed the zoom level, reset it unless they manually toggled the zoom level after us. In that condition,controlZoomLevelRef
is set tofalse
.Testing Instructions
The key concepts here are:
So, with these in mind, we have two scenarios to watch for:
From full screen mode
From full screen mode, exit zoom out manually
Screen Recording
Screen.Recording.2024-12-05.at.9.13.47.AM.mov