0

I’m implementing a "Guided Tour" feature using the native HTML Popover API. To ensure the user doesn't click background elements during the tour, I am applying the inert attribute to my <main> wrapper.

However, I’ve hit a wall. One of my popovers is nested deep inside the <main> container for component scoping reasons. Even though the popover is technically promoted to the Top Layer (appearing above everything else in the stacking order), I cannot click any buttons inside the popover or even dismiss it via keyboard when inert is active on the parent.

<main id="app-content">
  <button>Background Link</button>

  <div id="tour-step-1" popover>
    <p>Click 'Next' to continue</p>
    <button onclick="nextStep()">Next</button> 
  </div>
</main>

<button onclick="startTour()">Start Tour</button>

What I've tried:

  1. Calling showPopover() on the div. It appears visually on top of everything.

  2. Setting document.getElementById('app-content').inert = true;.

  3. The Issue: Once inert is true, the "Next" button inside the popover becomes unclickable, even though it's visually in the Top Layer and not clipped by the parent.

I thought the Top Layer was independent of the DOM tree's limitations. If a popover is "out of the flow," why is it still inheriting the "inertness" of its DOM parent?

New contributor
unknown is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

1

Move the popover element so it is not a child of the element you are making inert. The best practice is to place your popovers/dialogs as direct children of the <body> or wrap your main content in a separate container from your UI overlays.

<body>
  <main id="app-content">
    </main>

  <div id="tour-step-1" popover>
    <button>Next</button>
  </div>
</body>
New contributor
ssd is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.