Skip to content

[Bug] Tooltip: a tooltip dismissed with Escape opens again while the pointer stays on its trigger #11895

Open

Description

@duytbp

Description

A tooltip dismissed with Escape opens again while the mouse pointer stays on its trigger. When the tooltip surface covers the resting pointer, as it can over a trigger whose hit area reaches past its box, each Escape only hides it for the hover delay: hiding the surface puts the trigger back under the pointer, the browser fires mouseenter on it with no pointer movement, and the tooltip shows again. A dialog or sheet under the tooltip never gets the next Escape, so a keyboard user can't close it without moving the mouse.

Cause: onDismiss in useTooltip hides the layer but records nothing (useTooltip.tsx#L912-L946), and the trigger's next mouseenter schedules a show as for a new hover (#L515-L523, listener at #L772). WCAG 1.4.13 asks that hover content be dismissible "without moving pointer hover or keyboard focus"; content that comes back while the pointer stays put isn't dismissed.

Related: #11605 and its open fix #11831 start the show delay only on a pointer move. That stops the loop below, which has no move, but a dismissed tooltip still opens again on the first small move inside its trigger.

Reproduction

import {Tooltip} from '@astryxdesign/core/Tooltip';

// A trigger whose hit area reaches 16px past its box, as a touch-size target does.
const css = `.trigger{position:relative} .trigger::after{content:'';position:absolute;inset:-16px}`;

export function Repro() {
  return (
    <div style={{padding: 120}}>
      <style>{css}</style>
      <Tooltip content="Describes the button">
        <button className="trigger">Hover me</button>
      </Tooltip>
    </div>
  );
}
  1. Move the mouse to 6px above the button (inside its hit area) and keep it still. The tooltip opens above the button, under the pointer.
  2. Press Escape, wait 600ms, and repeat.

Actual: after each Escape the trigger receives pointerenter and mouseenter (no pointermove), and the tooltip is :popover-open again 600ms later, every time.
Control: with the pointer resting on the button's centre, outside the surface, one Escape closes the tooltip for good.
Expected: a tooltip dismissed with Escape stays closed until the pointer leaves its trigger and enters it again, or until focus leaves and comes back.

Workaround: an app can stop the trigger's mouseenter in the capture phase after an Escape until a pointermove lands outside the trigger.

Astryx Version

@astryxdesign/core@0.7.16, unchanged on main (b1441b7)

Environment

Firefox 157 and Chromium 156 (Playwright, headless), Linux; the repro above bundled with Vite, with the trusted events logged on the trigger. Firefox also shows it for a trigger under a resting pointer after another layer above it closes.

Activity

  1. ravindrasinghshah commented on Nov 15, 2026

    @ravindrasinghshah

    Hi, I'd like to take this one.

    My plan: in useTooltip, record an Escape dismissal in onDismiss and suppress the re-show until the pointer leaves the trigger and enters it again (or focus leaves and comes back), then add a regression test for the Escape-then-still-pointer case.

    How does this relate to the open fix #11831 for #11605 — should this be a separate PR, or folded into that work?

  2. duytbp commented on Nov 16, 2026

    @duytbp
    ContributorAuthor

    Thanks for taking it. I'd keep it a separate PR: #11831 is about a trigger that appears under a pointer that never moved, while this one is about re-showing after an Escape dismissal. They share useTooltip but have different conditions and tests, so separate PRs are easier to review and revert. If #11831 lands first, build on it. Your plan (suppress until the pointer leaves and re-enters, or focus leaves and returns) matches the expected behaviour in the report.

  3. cixzhang commented on Nov 19, 2026

    @cixzhang
    Contributor

    (Posted by Cindy's agent.) Thanks @duytbp for the report. A tooltip dismissed with Escape should stay dismissed while the pointer rests on its trigger, so this is a bug. @ravindrasinghshah, if you're still working on it, please open a PR; otherwise we'll pick it up and credit your plan. We'll update here.

  4. ravindrasinghshah commented on Nov 19, 2026

    @ravindrasinghshah

    (Posted by Cindy's agent.) Thanks @duytbp for the report. A tooltip dismissed with Escape should stay dismissed while the pointer rests on its trigger, so this is a bug. @ravindrasinghshah, if you're still working on it, please open a PR; otherwise we'll pick it up and credit your plan. We'll update here.

    @cixzhang - Thank you for confirming, I have raised the PR for review.

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

    lane:1Astryx fix-loop lane 1 owns this

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions