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

Zoom out mode doesn't persist when switching to code editor or between templates #65783

Closed
2 tasks done
simison opened this issue Oct 1, 2024 · 4 comments · Fixed by #65932
Closed
2 tasks done

Zoom out mode doesn't persist when switching to code editor or between templates #65783

simison opened this issue Oct 1, 2024 · 4 comments · Fixed by #65932
Assignees
Labels
[Feature] Zoom Out [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@simison
Copy link
Member

simison commented Oct 1, 2024

Description

When in zoomed-out view and switching to the code editor, the zoomed-out mode doesn't persist when closing the code editor. However, the button in the header remains active.

Step-by-step reproduction instructions

Enable zoomed-out view (tested in post editor):

Screenshot 2024-10-01 at 14 13 48

Switch to code editor:

Screenshot 2024-10-01 at 14 13 59

Exit code editor:

Screenshot 2024-10-01 at 14 14 33

Note how the editor isn't in zoomed-out mode but the zoomed-out button remains active:

Screenshot 2024-10-01 at 14 14 46

Screenshots, screen recording, code snippet

No response

Environment info

  • Gutenberg trunk as of Oct 1
  • Chrome

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes
@simison simison added [Type] Bug An existing feature does not function as intended [Feature] Zoom Out labels Oct 1, 2024
@simison
Copy link
Member Author

simison commented Oct 1, 2024

I expected to stay in the zoomed out mode, but if that's not what should happen, then the button at least shouldn't remain active upon switching to code editor.

@madhusudhand
Copy link
Member

The same issue observed while switching templates:

Steps:

  1. Go to zoom out mode
  2. Switch to a different template
  3. Zoom out button stays active, but the content goes to normal mode.

@getdave
Copy link
Contributor

getdave commented Oct 7, 2024

I suspect that the state for Zoom Out is still "active" but the UI has reset itself. There maybe an effect or listener that handles toggling the "zoom" that we need to make more intelligent / reactive.

Update: I tested and indeed it is only the "zooming of the canvas" that isn't displayed properly. The actual "zoom out" mode remains active.

@madhusudhand
Copy link
Member

Update: I tested and indeed it is only the "zooming of the canvas" that isn't displayed properly. The actual "zoom out" mode remains active.

Yes, zoom out remains active.

The issue is due to value of prevContainerWidthRef.current being undefined
It is because the component is removed from the dom and added again, when switched to code editor and then back to editor

I have put this condition, it works for code editor switching (because the container width doesn't change), but fails when switching to different template.

I guess we either need to save prevContainerWidth in the store or in the localStorage may be?

@getdave thoughts?

@getdave getdave changed the title Zoom out mode doesn't persist when switching to code editor Zoom out mode doesn't persist when switching to code editor or between templates Oct 8, 2024
@github-project-automation github-project-automation bot moved this from 🏗️ In Progress to ✅ Done in WordPress 6.7 Editor Tasks Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Zoom Out [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants