Skip to content

[6.x] Fix mobile nav button failing#14673

Open
jaygeorge wants to merge 2 commits into
6.xfrom
fix-mobile-nav-button-failing
Open

[6.x] Fix mobile nav button failing#14673
jaygeorge wants to merge 2 commits into
6.xfrom
fix-mobile-nav-button-failing

Conversation

@jaygeorge
Copy link
Copy Markdown
Contributor

Description of the Problem

If you pull the window in so the nav switches to a burger state, it sometimes fails to function on page load.

The nav talked to the sidebar through Statamic.$events, which was flagged as flaky (click/timing races, especially on mobile), and the drawer could flash on screen before JS added the right classes.

Nav.Failing.mp4

What this PR Does

  • Uses a small direct “call this function” hook between Logo and Nav instead of events
  • Ignore outside-clicks on the burger
  • CSS changes to keep the mobile drawer off-screen before JS runs.
  • Also fixes the nav overflow height, taking the dynamic address bar UI into consideration

To be honest, I think this nav should be a popover, which would be less fragile and drastically simplify things – but that's probably an even bigger change, and something to consider in future if we start changing the component.

You can see the behaviour is fixed now:

Nav.Working.mp4

How to Reproduce

  1. Make the viewport narrow so you can see the nav burger
  2. Make sure DevTools are closed so caching is not force-cleared on load
  3. Toggle the nav in
  4. Reload the page
  5. Try toggling the nav again. It will not work until you load the page a third time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant