Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When using the Olivero theme, if an item within the main content has a high z-index (such as the carousel using the flex-slider module) the element with the high z-index will appear in front of the mobile slide out menu.
Steps to reproduce
Have a high z-index piece of element in the main content area (such as a dynamic carousel that affects z-index), or you can create your own markup with something like
<div style="position: relative; z-index: 1000; background: pink; padding: 20px;">
This block has a z-index of 1000
</div>
Testing steps
- Create a high z-index element using the code above
- Notice that this element obscures the mobile menu when open.
- Apply the patch (or view the Tugboat URL: https://3250357-13-z-index-fuoovipqv4lkycp8mbvjgo7cgpqgnkuf.tugboat.qa/)
- Verify that its fixed.
- Verify that the wide dropdowns and search dropdown work as expected.
Comment | File | Size | Author |
---|---|---|---|
#24 | Screenshot 2021-12-19 at 4.19.19 PM.png | 91.52 KB | Gauravvvv |
#24 | Screen Recording 2021-12-19 at 4.20.26 PM.mov | 6.17 MB | Gauravvvv |
#22 | 3250357-10.0.x-22.patch | 10.02 KB | mherchel |
| |||
#21 | 3250357-21.patch | 9.98 KB | mherchel |
#21 | interdiff-13-21.patch | 3.89 KB | mherchel |
Comments
Comment #2
mherchelDid a little looking at this. This is being caused by Flexslider setting a
z-index: 2
inline-style within the content. This can be fixed by doing something likeHowever IMHO Olivero should be able to support this. If we set
z-index: 3
on the.site-header
it also fixes the problem. We need to be careful about changing around z-indexes though, because they can be tricky to debug and find problems.Can't work on this right now, but I think this is something that we can fix within the theme.
Comment #3
mherchelAlso, thanks for the bug report @Tim Robinson!
Comment #4
kostyashupenkoyep, @mherchel you are absolutely right.
Also this bug happens also on desktop device if
Enable mobile menu at all widths
option enabled for Olivero theme. Just add:to the any element from
main
section and try to expand burger menu. So i decided to add z-index directly to.site-header
selector. From what i see there was no any side-affects after this change.Also this bug happens to the
.overlay
selector, which doesn't have z-index at all (so overlay lives "under" main content if it has z-index defined). As i see from js we use this selector only in terms of navigation, so i have added z-index to the overlay aswell.This task needs review now in all browsers defined here: https://www.drupal.org/project/drupal/issues/3173877
How to quickly test things:
1. You have to open locally this file https://git.drupalcode.org/project/drupal/-/blob/9.2.x/core/themes/olive... and change lines like this:
^ this is a custom text with highlighted background and long text, with z-index hardcoded -> it needs just to test header (long text here required to be able to test theme with
Enable mobile menu at all widths
option enabled on desktop).So after this change you have to clear drupal cache and then you will see your custom text on homepage.
If it's complicated for you to find this twig file and modify, you can go to
/node/add/article
page, fill theTitle
field and after forBody
field change Text format toFull HTML
, then click onSource
button in CKEditor and put this content inside:Click save and then you can test this task on your newly created node page.
2. Go through the all browsers, test on mobile/desktop and report here if bug is still exist. No need to report thousands screenshots here from all browsers. Just provide 1 or 2 screenshots here if bug exist somewhere still + explanations where problem still exist.
P.S.: you can enable
Enable mobile menu at all widths
option on this page/admin/appearance/settings/olivero
on the bottom.3. You probably have to pay a lot of attention on header and its animating effects on expanding/collapsing menu. if you will find some "ugly" or/and unexpected/weird behaviors even if no problem anymore with original issue related to z-index - please report it here aswell.
Comment #5
Tim Robinson CreditAttribution: Tim Robinson as a volunteer commented@mhercel and @kostyashupenko - thank you very much for your prompt responses. I’ve applied the fix to the four affected files, created the test article, cleared caches and enabled the mobile menu at all widths to test successfully in iOS Safari, iPad OS Safari, macOS Big Sur Safari and macOS Big Sur Microsoft Edge. No screenshots attached because all seems to be working as expected. I’m afraid I am not in a position to complete testing across all required browsers, nor should my testing be treated as authoritative.
Comment #6
kostyashupenkoTagging
Comment #7
kostyashupenkoTagging back to `Needs review`, since anyway at least one or two screenshots (or video/s) expected to see if original issue has gone.
Comment #8
Tim Robinson CreditAttribution: Tim Robinson as a volunteer commentedOK. I have attached four screenshots from:
iOS - Safari where the menu covers the whole of the screen
iPadOS - Safari
macOS Big Sur - Safari
macOS Big Sur - Microsoft Edge - this file shows the menu on top of Flex Slider content.
These screenshots were after applying @kostyashupenko fixes to the four Olivero files referred to in the fix when running Drupal 9.2.9. The fix appears to be successful with behaviour as expected.
Once again, thanks very much @kostyashupenko
Comment #9
Tim Robinson CreditAttribution: Tim Robinson as a volunteer commentedSorry, error on file upload. This is the iPad OS file.
Comment #10
kostyashupenkoThanks for screenshots
Comment #11
mherchelI discussed this with @lauriii earlier today, and we brainstormed a fix for this.
The fix in #4 works, but it conflicts with the z-index of jquery joyride (the tour module), in addition, any elements with z-indexes above 101 within the main content will appear above the nav.
A better way would be to create stacking contexts on each of the main wrapping elements:
.site-header
,. layout-main-wrapper
, and.site-footer
. If we set the.site-header
's z-index to 10, and the others to 1, it will always ensure that the header appears above the other wrappers (even if they contain elements that have higher z-indexes). We'll also need to move the overlay element into the.site-header
wrapper, and if we do that, we should probably change it's name.For anyone following along with this, z-indexes are more confusing than they appear. A good article on this is https://www.lullabot.com/articles/understanding-debugging-stacking-contexts
New patch incoming shortly.
Comment #12
mherchelComment #13
mherchelPatch attached.
Tugboat link: https://3250357-13-z-index-fuoovipqv4lkycp8mbvjgo7cgpqgnkuf.tugboat.qa/
Comment #14
mherchelAdding testing steps
Comment #15
andy-blumThis looks pretty good - my main concern was how this would impact dialogs & overlays, but that seems to be handled well (see attached screeshots)
Comment #16
andy-blumOh, found an edge case. Having the offcanvas-top dialog open with the mobile menu has some issues.
Comment #17
mherchelLooks like this is a pre-existing issue. You can test this out on the latest 9.4.x at https://tugboat-aqrmztryfqsezpvnghut1cszck2wwasr.tugboat.qa/dialog
Opened followup #3251407: Olivero should use Drupal.displace() to place the mobile menu
Comment #18
andy-blumin that case, moving patch 12 to RTBC per comment 15
Comment #19
andy-blumin that case, moving patch 12 to RTBC per comment 15
Comment #20
lauriiiThis still conflicts with Tour and Quickedit. For example, Quickedit is still rendered on top of the mobile menu. I think we should change the tour z-index so that there's space between Quickedit and Tour for elements that need to render above Quickedit, but below Tour.
Comment #21
mherchelNew patch attached for 9.4.x
A couple notes:
Tugboat URL for 9.4.x: https://3250357-z-index-21-2-avwcbvuimsn13sxldl3daue72nvsr0oh.tugboat.qa/
Comment #22
mherchelPatch for 10.0.x attached.
Comment #23
mherchelComment #24
Gauravvvv CreditAttribution: Gauravvvv at Srijan | A Material+ Company for Drupal India Association commentedI tested and verified patch #21, Fixes the issue.
Added before patch screenshot and after patch screen recording. Tested with tour module and menu in mobile device.
Can be move to RTBC
Comment #25
Gauravvvv CreditAttribution: Gauravvvv at Srijan | A Material+ Company for Drupal India Association commentedComment #26
mherchelThanks for the review! Setting to RTBC per the comment in #24
Comment #27
lauriiiCan we get a change record for changing the Tour z-indices? We should also update https://www.drupal.org/node/2823900
Comment #28
mherchelChange record: https://www.drupal.org/node/3258948
Comment #29
mherchelUpdated docs https://www.drupal.org/docs/theming-drupal/z-indexes-in-drupal-8#comment...
Comment #32
lauriiiCommitted baa8211 and pushed to 10.0.x. Also committed the 9.4.x patch to 9.4.x. Thanks!