Skip to content

fix(tooltip): ignore mouseenter that follows no mouseleave - #1442

Open
rene-schakmann wants to merge 1 commit into
openng-org:mainfrom
rene-schakmann:fix/issue-950-tooltip-reappears-on-overlay-close
Open

fix(tooltip): ignore mouseenter that follows no mouseleave#1442
rene-schakmann wants to merge 1 commit into
openng-org:mainfrom
rene-schakmann:fix/issue-950-tooltip-reappears-on-overlay-close

Conversation

@rene-schakmann

Copy link
Copy Markdown

Fixes #950 — tooltip reappears after selecting an item, with ripple enabled, in Chrome.

Root cause

The overlay of a p-select / p-dropdown is rendered inside the tooltipped host (appendTo defaults to 'self'), so the option <li> the pointer sits on is a descendant of the element Tooltip listens on.

Selecting an option detaches that <li> — together with the <span class="p-ink"> of its running ripple animation. Chrome then re-runs its hover computation for the detached subtree and dispatches a fresh mouseenter at the host: no pointer movement, and no mouseleave in between. Tooltip.onMouseEnter only guarded on !this.container && !this.showTimeout, both true right after the click hid the tooltip, so it re-showed the tooltip that the very same click had just dismissed — leaving it on screen while the pointer is nowhere near the host.

Firefox only recomputes hover on real pointer movement, which is why the report is Chrome-only. Removing the ripple ink from the DOM makes the spurious enter disappear as well, matching "only when ripple is enabled" from the report.

Instrumented event log from the reproduction (pointer stationary throughout):

t=7900  click       on host (option click bubbles up) -> deactivate(), tooltip hidden
t=7912  mouseenter  on host, x/y unchanged, no mouseleave  -> activate(), tooltip back

The fix

An enter that is not preceded by a leave is not a new hover. Tooltip now tracks whether the pointer is already inside the host and ignores those re-entrant events. Genuine hover, leave/re-enter, focus and touch paths are untouched.

Verification

Reproduced in the environment named in the issue — Angular 15 + PrimeNG 15, ripple on via PrimeNGConfig, pTooltip on p-dropdown, Chrome 108 in Docker — driven over WebDriver with real pointer events and no pointer movement after the item click.

Before After
before after

"Rome" is selected in both; on the left the tooltip is stranded next to the closed dropdown.

  • 6 new specs in tooltip.spec.ts covering the invariant end to end. 3 of them fail without the fix and pass with it.
  • pnpm run test:unit: 7210 passing. The single failure is ScrollTop Performance should handle rapid scroll events efficiently, which is timing-sensitive under full-suite load and passes when scrolltop.spec.ts runs on its own — unrelated to this change.
  • pnpm run format:check clean. Note: pnpm run lint fails on main as well (eslint --ignore-path is not valid with the flat config), so it could not be used as a gate here; eslint run directly on the changed files reports no errors.
  • Checked in the docs app on Chrome 150 that hover, leave/re-hover and select-an-option all behave.

Co-authored by Claude.

With ripple enabled, selecting an item from an overlay that is rendered inside a
tooltipped host detaches the element the pointer sits on, together with the ink
span of its running ripple animation. Chrome re-runs its hover computation for
the detached subtree and dispatches a fresh mouseenter at the host - no pointer
movement, no preceding mouseleave - which re-showed the tooltip that the very
same click had just dismissed. Firefox only recomputes hover on real pointer
movement, hence the browser difference in the report.

An enter that is not preceded by a leave is not a new hover, so track whether
the pointer is already inside the host and ignore those events.

Fixes openng-org#950
@geromegrignon geromegrignon added this to the Catch-up milestone Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tooltip: Persists when dropdown is closed and ripple enabled

2 participants