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

Website: Replace 100vh with 100dvh to fix an "unscrollable" state on mobile devices #1883

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

adamziel
Copy link
Collaborator

On iPhones, 100vh may exceed the actual viewport size – Safari viewport height varies as you scroll the page and vh seems to represent the largest possible viewport.

When opening an anchor link (/#wp-admin), the browser wants to scroll down and align the top of the screen with the WordPress site. This causes Playground to occasionally end up in a slightly scrolled state where only the WordPress site is visible and you cannot scroll back to the Playground address bar:

IMG_7D8D2EADEECC-1

Why? Because:

  • 100vh makes the page longer than it needs to be
  • The difference is just enough to span the entire Playground address bar. On the screenshot above I intentionally left just a glimpse of that address bar, but it isn't normally there.
  • WordPress iframe has its own scrollbar so, by scrolling, you're only moving up and down the WordPress page

Solution: Use dvh unit

There's a special dvh unit that represents the current height of the viewport:

plYwy

Testing Instructions (or ideally a Blueprint)

  1. Open Playground on an iPhone or a simulator (16 Pro Max in my case)
  2. Create a bunch of sites, preview Blueprints etc
  3. Confirm that before this PR this puts you in an unscrollable state
  4. Confirm that with this PR you can always see the browser UI

cc @annziel this might interest you

On iPhones, 100vh may exceed the actual viewport size. Safari
viewport height varies as you scroll the page. There's a special
`dvh` unit that represents the current height of the viewport so
I'm switching all vh to dvh.
@adamziel adamziel changed the title Website: Replace 100vh with 100dvh Website: Replace 100vh with 100dvh to fix an "unscrollable" state on mobile devices Oct 10, 2024
@adamziel adamziel merged commit 32ad567 into trunk Oct 10, 2024
9 checks passed
@adamziel adamziel deleted the use-dvh branch October 10, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant