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

Toolbars and inserters are displaced by editor chrome #65188

Closed
getdave opened this issue Sep 10, 2024 · 15 comments · Fixed by #66034
Closed

Toolbars and inserters are displaced by editor chrome #65188

getdave opened this issue Sep 10, 2024 · 15 comments · Fixed by #66034
Assignees
Labels
[Feature] Zoom Out [Priority] High Used to indicate top priority items that need quick attention [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@getdave
Copy link
Contributor

getdave commented Sep 10, 2024

In Firefox the Zoom Out mode toolbar can become detacthed from the sections when you activate the Blocks tab of the inserter.

displaced.toolbars.mp4

## Reproduction steps

  • Enable Zoom Out Mode experiment
  • Site Editor -> Activate Zoom Out mode
  • Select a "section"
  • Open the inserter
  • See the Zoom Out toolbar is misplaced until you hover over the block's in the canvas again.
@getdave getdave added [Type] Bug An existing feature does not function as intended [Feature] Zoom Out labels Sep 10, 2024
@getdave getdave changed the title Fix vertical toolbar placement in Zoom Out mode in Firefox Fix vertical toolbar placement in Zoom Out mode Sep 10, 2024
@AhmarZaidi
Copy link
Contributor

AhmarZaidi commented Sep 16, 2024

Hey 👋,
I'd like to work on this issue.

I believe the reason toolbar is becoming detacthed is that the update function for it's position is dependent on the reference of the underlying block and that doesn't get updated when we toggle the inserter.

Here are the auto update options for the useFloating hook that is used by the toolbar.
As we can see in the autoupdate options, it does update the toolbar position on scroll or resize and also on layoutshift. But the layout shift option only applies to the reference element.

Also, along with the zoom out toolbar, the add pattern button is also getting detached.


One solution to fix both the elements getting detached is to add MutationObserver on the parent div of the inserter (interface-interface-skeleton__body).
I've tested that and it seems to work fine.
The autoUpdate also adds MutationObserver and ResizeObservers under the hood.

Should we go with this approach?

@getdave
Copy link
Contributor Author

getdave commented Sep 16, 2024

@AhmarZaidi Thank you. Yes it would be great to have you contribute to this effort.

Please feel free to raise a PR with your proposed solution 👍

@AhmarZaidi
Copy link
Contributor

Hey @getdave raised a PR for this issue here

@annezazu annezazu added the [Priority] High Used to indicate top priority items that need quick attention label Oct 7, 2024
@draganescu draganescu changed the title Fix vertical toolbar placement in Zoom Out mode Toolbars and inseters are displaced by editor chrome Oct 8, 2024
@draganescu
Copy link
Contributor

Despite improving anchoring #65627 does not fix this issue.

@draganescu
Copy link
Contributor

#65654 is a similar issue. I'll close it in favor of this one.

@colorful-tones colorful-tones changed the title Toolbars and inseters are displaced by editor chrome Toolbars and inserters are displaced by editor chrome Oct 8, 2024
@draganescu draganescu self-assigned this Oct 9, 2024
@ciampo
Copy link
Contributor

ciampo commented Oct 9, 2024

While taking a look at #65981, I noticed these styles being applied to the iframe container. I noticed that the container is much wider than the available space, and margin-left and width are changed:

  • the new values seem off, since they cause the container to go partially offscreen;
  • they cause glitches with the scroll bar (see attached video);
  • they are not as performant to animate as using CSS transform;
  • they also seem to be related to the toolbar getting out of place when opening/closing the outline sidebar;

This is the scrollbar glitch mentioned above:

Kapture.2024-10-09.at.22.49.13.mp4

And this the bug described in this PR being fixed by disabling those margin-left and width styles:

Kapture.2024-10-09.at.22.47.51.mp4

@draganescu
Copy link
Contributor

@ciampo yes but disabling the margin and the width breaks the UI in the sense that opening more chrome results in the canvas shrinking more and more.

@ciampo
Copy link
Contributor

ciampo commented Oct 10, 2024

yes but disabling the margin and the width breaks the UI in the sense that opening more chrome results in the canvas shrinking more and more.

I understand — what I'm suggesting is that maybe this bug could be fixed by tweaking the "resizing styles", in particular by making the iframe container as wide as the available width in the viewport (currently it's larger)

@kevin940726
Copy link
Member

I agree with @ciampo that a more proper fix might be fixing the iframe's width. Currently, when enabling zoom-out, the scrollbar is hidden under the sidebar, making it inaccessible.

Image

@kevin940726
Copy link
Member

kevin940726 commented Oct 10, 2024

@ciampo How confident are you to try out a PR with the above change in #65188 (comment)? Should we punt this to 6.8 or maybe 6.7.1 if that needs more work?

@draganescu
Copy link
Contributor

draganescu commented Oct 10, 2024

We should fix this for 6.7 IMO. Will help with any PR @ciampo gets going and I am also ;ooking at whether fixing the issue with width/margin values (I think we need to keep them to preserve the UX) solves the problem in the issue here. Otherwise my PR adding an observer may be a good patch for a while. I'd hate to have UI displacement just ship in 6.7.

For the record just removing the styles reults in this

reflow-no-margin-width.mp4

This causes that reflow which we're working hard to tweak into non existence as we speak.

@kevin940726
Copy link
Member

Currently, when enabling zoom-out, the scrollbar is hidden under the sidebar, making it inaccessible.

This was reported in #65595.

@draganescu
Copy link
Contributor

draganescu commented Oct 10, 2024

The width of the container of the iframe is so big because it is preserving the size of the viewport as it was before zoom out. This enables the iframe to extend into it to 100% and this in turn makes the browser keep the same media queries active.

Attempting the same effect by applying margin and width to the iframe instead of the container does not fix the problem with UI displacement. Resizing the iframe fixes the problem with UI displacement, but breaks the feature. Scaling the iframe instead of the html keeps the iframe as wide as the workbench (gray area) which triggers media querries in zoom out when opening chrome.

Tested the refactor in #63390 and the UI displacement is still there.

@ciampo
Copy link
Contributor

ciampo commented Oct 10, 2024

I'm going to timebox an effort, hopefully today or at the latest tomorrow

@getdave
Copy link
Contributor Author

getdave commented Oct 10, 2024

I'd hate to have UI displacement just ship in 6.7.

I think we need to meet this bar for quality for 6.7 👍 It's highly likely folks will encounter this UI glitch as they open/close the Patterns inserter.

Thanks to everyone for digging into this in such detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Zoom Out [Priority] High Used to indicate top priority items that need quick attention [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
Status: Done
7 participants