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

  1. Create a high z-index element using the code above
  2. Notice that this element obscures the mobile menu when open.
  3. Apply the patch (or view the Tugboat URL: https://3250357-13-z-index-fuoovipqv4lkycp8mbvjgo7cgpqgnkuf.tugboat.qa/)
  4. Verify that its fixed.
  5. Verify that the wide dropdowns and search dropdown work as expected.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Tim Robinson created an issue. See original summary.

mherchel’s picture

Did 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 like

[data-thumb-alt] {
  z-index: auto !important;
}

However 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.

mherchel’s picture

Also, thanks for the bug report @Tim Robinson!

kostyashupenko’s picture

Status: Active » Needs review
FileSize
1.56 KB

yep, @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:

  position: relative;
  z-index: 2;

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:

    <main role="main">
      <div style="background-color: #98faff; position: relative; z-index: 2;">Custom text with z-index: 2; tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata</div>
      {{ page.content_above }}
      {{ page.content }}
    </main>

^ 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 the Title field and after for Body field change Text format to Full HTML, then click on Source button in CKEditor and put this content inside:

    <div style="background-color: #98faff; position: relative; z-index: 2;">Custom text with z-index: 2; tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata tratata</div>

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.

Tim Robinson’s picture

Status: Needs review » Active

@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.

kostyashupenko’s picture

Status: Active » Reviewed & tested by the community

Tagging

kostyashupenko’s picture

Status: Reviewed & tested by the community » Needs review

Tagging back to `Needs review`, since anyway at least one or two screenshots (or video/s) expected to see if original issue has gone.

Tim Robinson’s picture

FileSize
202.83 KB
202.83 KB
1004.4 KB
1.8 MB

OK. 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

Tim Robinson’s picture

FileSize
665.99 KB

Sorry, error on file upload. This is the iPad OS file.

kostyashupenko’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for screenshots

mherchel’s picture

Version: 9.2.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +CSS

I 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.

mherchel’s picture

Title: Main menu appears underneath Flex Slider content » Olivero: Elements within main content that have a high z-index will appear in front of mobile nav
mherchel’s picture

Status: Needs work » Needs review
FileSize
7.78 KB
mherchel’s picture

Issue summary: View changes

Adding testing steps

andy-blum’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
214.96 KB
89.32 KB
142.61 KB
104.35 KB
133.82 KB
112.94 KB

This looks pretty good - my main concern was how this would impact dialogs & overlays, but that seems to be handled well (see attached screeshots)

andy-blum’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
120 KB

Oh, found an edge case. Having the offcanvas-top dialog open with the mobile menu has some issues.

mherchel’s picture

Status: Needs work » Needs review

Looks 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

andy-blum’s picture

in that case, moving patch 12 to RTBC per comment 15

andy-blum’s picture

Status: Needs review » Reviewed & tested by the community

in that case, moving patch 12 to RTBC per comment 15

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

This 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.

mherchel’s picture

New patch attached for 9.4.x

A couple notes:

  • Quickedit has a z-index of 100 and appears at the end of the DOM tree. This means that the header must have a z-index higher. It was changed to 101.
  • The contextual link in the site branding needs to be covered up by the navigation. This element is within the DOM structure of the header and has a z-index of 500. This necessitates taking the z-index of the .header-nav to 501.
  • Because we increase the z-index of the header-nav, we must now increase the z-index of the mobile navigation button (.mobile-nav-button ) to 505.
  • The tour module has two elements at the end of the DOM:
    • .sheperd-element is set to 100 (this is the modal container).
    • .sheperd-modal-overlay-container is set to 100 (this is the overlay).
  • I had to separate these and move them slightly so that they'd appear above the navigation.
  • .sheperd-element is now at 110
  • .sheperd-modal-overlay-container is now at 105

Tugboat URL for 9.4.x: https://3250357-z-index-21-2-avwcbvuimsn13sxldl3daue72nvsr0oh.tugboat.qa/

mherchel’s picture

Status: Needs work » Needs review
FileSize
10.02 KB

Patch for 10.0.x attached.

mherchel’s picture

Issue summary: View changes
Gauravvvv’s picture

I 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

Gauravvvv’s picture

mherchel’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the review! Setting to RTBC per the comment in #24

lauriii’s picture

Issue tags: +Needs change record

Can we get a change record for changing the Tour z-indices? We should also update https://www.drupal.org/node/2823900

mherchel’s picture

mherchel’s picture

  • lauriii committed baa8211 on 10.0.x
    Issue #3250357 by mherchel, kostyashupenko, andy-blum, Tim Robinson,...

  • lauriii committed 37f42e8 on 9.4.x
    Issue #3250357 by mherchel, kostyashupenko, andy-blum, Tim Robinson,...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs change record

Committed baa8211 and pushed to 10.0.x. Also committed the 9.4.x patch to 9.4.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.