Skip to content

Escape does nothing while a manual popover is open, wherever focus is #5582

Closed

Description

@max-sixty

While a popover="manual" element is open, Escape does nothing anywhere on the page. Focus stays where it is and the popover stays open, press after press. In the floating panel's comment field, Escape no longer leaves the field. On a link, it no longer lets go.

I hit this with a widget that shows a hover card as a manual popover while the pointer rests on a word. While writing a comment with the pointer over such a word, Escape stopped working until the pointer moved away.

Repro. Serve this page with leaf server run:

<!doctype html>
<html lang="en">
  <head><title>Escape under a hover card</title></head>
  <body>
    <main>
      <p id="para">
        <span id="word">Hover this word</span>, or focus this <a id="link" href="#para">link</a>.
      </p>
      <div id="card" popover="manual">A card</div>
    </main>
    <script>
      const word = document.getElementById("word");
      const card = document.getElementById("card");
      word.addEventListener("mouseenter", () => card.showPopover({ source: word }));
      word.addEventListener("mouseleave", () => card.matches(":popover-open") && card.hidePopover());
    </script>
  </body>
</html>

Click into the floating panel's comment field and type a word, or focus the link. Rest the pointer on "Hover this word", then press Escape three times. Repeating it with popover="auto" and popover="hint" gives the last two rows. Headless Chromium 156 on Linux, driven by Playwright:

Card Escape 1 Escape 2 Escape 3
none hovered leaves the field or the link
manual nothing nothing nothing
auto closes the card leaves the field or the link
hint closes the card leaves the field or the link

Where it comes from. In keyboard/page.js, the let-go (navigation.release, through currentLocationFloor) and the page rung ("back to the page") both stand down while nativeLayers() is non-empty: "a popover or a modal is the browser's own mode, its own scope is the way out of it". With no view open, the comment field has no Escape of its own, since panel.floating.leave is live only while a view is open, so leaving it falls to those steps. keyboard/dispatch.js also puts a POPOVER_BOUNDARY after each layer, which claims Escape. Its comment says "Auto popovers and modal dialogs are the platform's modes", but the layer stack records every open popover, manual ones included. An unhandled Escape goes on to the browser, which closes auto and hint popovers. The platform never closes a manual one on Escape, so nothing takes the press.

Expected. Escape takes a step whenever one stands. A manual popover the user isn't in holds no focus and has no platform dismissal, so it shouldn't stand down the steps beneath it. Here those are leaving the comment field and letting go of the link. One way would count a manual popover as an Escape layer only while focus is inside it. Another would let Escape fall through a layer that has no live step and that the platform won't close. Declaring an Escape row on the card would close it first. But that spends a press on a card the user never entered, and a page script that doesn't declare one leaves the whole page without Escape.

Workaround. A widget can close its own hover card in a capture-phase keydown listener on window, before Leaf reads the layer stack, and let the press go on.

Seen on leaf a8310f0, installed 2026-11-05T15:05:08-08:00.

This was written by Claude Code on behalf of max-sixty

Activity

  1. added
    bug
    on Nov 6, 2026
  2. leaf-agent commented on Nov 6, 2026

    @leaf-agent
    Collaborator

    #5593 fixes this. Leaf now counts a manual popover as an Escape layer only while focus is inside it, which was the first option you suggested. nativeModes() in keyboard/layer-stack.js returns modals, auto and hint popovers, and manual popovers that hold focus. The dispatcher's tiers and the let-go and "back to the page" steps in keyboard/page.js read it instead of the whole layer stack. So with your hover card open under the pointer, Escape leaves the comment field or lets go of the link, the same as with no card open. With focus inside the card, Escape still holds there.

    The regression test uses the page from the issue. It fails on main at the link's Escape and passes with the change. The neighbouring popover and Escape tests, test:runtime and pnpm run check also pass locally. CI and review on the PR are still pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions