Skip to content

Conversation

@kylecarbs
Copy link
Member

Summary

On iOS Safari mobile PWA, when clicking an input and then unfocusing it, the header becomes offset upwards making the hamburger menu button unclickable. This PR fixes the issue by resetting the window scroll position when the virtual keyboard closes.

Background

iOS Safari has a known quirk where the visual viewport can remain scrolled after the virtual keyboard dismisses. When using position: fixed elements (like our mobile header with mobile-sticky-header class), they position relative to the layout viewport, not the visual viewport. If the page remains "scrolled" after keyboard dismissal, fixed elements appear shifted.

The interactive-widget=resizes-content viewport meta tag helps but doesn't fully resolve this in all scenarios.

Implementation

Added useMobileKeyboardFix hook that:

  1. Listens for visualViewport resize events (fires when keyboard opens/closes)
  2. When viewport height increases significantly (>50px, indicating keyboard closing), resets window.scrollTo(0, 0)
  3. Only activates on mobile touch devices (max-width: 768px + pointer: coarse)

The hook is called from AppInner to ensure it's active globally.

Validation

  • Typecheck passes
  • Static checks pass

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high • Cost: $0

On iOS Safari, when the virtual keyboard opens and closes, the visual
viewport can remain scrolled even after the keyboard dismisses. This
leaves fixed-position elements (like the mobile header) appearing offset
from their intended position, making the hamburger menu unclickable.

Add useMobileKeyboardFix hook that listens for visualViewport resize
events and resets window.scrollTo(0, 0) when the viewport height
increases (indicating keyboard closure). The hook is only active on
mobile touch devices where this bug occurs.
@github-actions github-actions bot added the bug label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant