Global Header/Navigation: Switch to observer for menu open & close actions #682
+23
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #678. The global header nav adds a class when opened,
has-global-modal-open
, but this was only being removed when the nav was closed by button click. This changes the way that class is removed by watching thehas-modal-open
class, which the core block adds, so that the custom class is always removed when the nav modal closes.I then used the same observer to fix #681, by simply scrolling to the top of the page when a nav is opened. I did try to fix the alignment via CSS, but it's fixed to the viewport position. Switching to
absolute
+ some other tweaks worked, but then the bottom was cut off.So I'm on the fence about whether this is too hacky — it does make the screen jump, but then everything is positioned perfectly… Here's an example:
nav-scroll.mp4
To test
Global header fix:
Detached menu fix:
This issue ^ appears on both the global header menus and local nav menus, so you can test both.