[2.x] Fix search modal overlapping the navigation drawer on mobile#4811
Open
karl-bullock wants to merge 1 commit into
Open
[2.x] Fix search modal overlapping the navigation drawer on mobile#4811karl-bullock wants to merge 1 commit into
karl-bullock wants to merge 1 commit into
Conversation
On phones the global search lives inside the slide-out drawer, which shares its z-index base (--zindex-modal) with the modal system. Opening the search modal without closing the drawer left it overlapping the modal for ~150ms while the modal animated in. Hide the drawer as search is activated so it slides out before the modal appears.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What / why
On phones the global search input is rendered inside the slide-out navigation drawer. Tapping it opens the full-screen
SearchModal, but the drawer is never closed first, so it visibly overlaps the modal while the modal animates in. The screen "glitches" for a moment and then corrects itself once the modal settles on top.Root cause
.App-draweris positioned atz-index: var(--zindex-modal)(1050), the same base the modal system builds on:ModalManager->calc(var(--zindex-modal) + var(--modal-number)).Modal-backdrop->calc(var(--zindex-modal) + var(--modal-count) - 2)While the modal mounts,
--modal-numberis0, so for ~50-150ms:1050and covers the left of the screen,1048/1049, i.e. below the drawer, so only the area the drawer does not cover gets dimmed, andModalManagerthen mounts at1050and the modal slides up over the drawer.The net effect is the drawer overlapping the opening search modal before it is finally covered.
Fix
Close the drawer as soon as search is activated, in the
Searchonclickhandler, before the modal is shown. Placing it here rather than insideopenSearchModallets the drawer finish its slide-out during the existing 150ms delay, so the modal opens over the page instead of over the drawer. Hiding it at modal-show time is too late: the drawer's 0.2s slide-out then races the modal and the overlap still shows.app.drawer.hide()returns early when the drawer is not open, so this is a no-op on wider screens and in the admin frontend (the search component is shared, andapp.draweris created by the commonApplication).Testing
Reproduced on a clean
2.0.0-rc.5install at a 390px viewport, opening the drawer and tapping search as both a guest and a logged-in user. Before the change the drawer overlaps the opening modal for ~150ms; after it, the drawer slides out first and the modal opens cleanly. I confirmed frame by frame that the.App-navigationheader (z-index 1000/1001) is never the element on top, so the mis-layering is the drawer versus the modal, not the header.