Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-toes-find.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

Tooltip: Prevents tooltip from appearing when popover (e.g. ActionMenu) is opened
19 changes: 14 additions & 5 deletions app/components/primer/alpha/tool_tip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class ToolTipElement extends HTMLElement {
#side: AnchorSide = 'outside-bottom'
#allowUpdatePosition = false
#showReason: 'focus' | 'mouse' = 'mouse'
#isControlsPopoverOpen = false
get showReason() {
return this.#showReason
}
Expand Down Expand Up @@ -247,20 +248,28 @@ class ToolTipElement extends HTMLElement {
if (!this.control) return
const showing = isPopoverOpen(this)

// Track when the control's popover (e.g an ActionMenu) is opened/closed
if (event.type === 'beforetoggle' && event.currentTarget !== this) {
this.#isControlsPopoverOpen = (event as ToggleEvent).newState === 'open'
}

// Ensures that tooltip stays open when hovering between tooltip and element
// WCAG Success Criterion 1.4.13 Hoverable
const shouldShow =
event.type === 'mouseenter' ||
// Only show tooltip on focus if running in headless browser (for tests) or if focus ring
// is visible (i.e. if user is using keyboard navigation)
(event.type === 'focus' && (navigator.webdriver || this.control.matches(':focus-visible')))
(event.type === 'mouseenter' ||
// Only show tooltip on focus if running in headless browser (for tests) or if focus ring
// is visible (i.e. if user is using keyboard navigation)
(event.type === 'focus' && (navigator.webdriver || this.control.matches(':focus-visible')))) &&
// Don't show tooltip if the control's popover is open (e.g. an ActionMenu)
!this.#isControlsPopoverOpen
Comment on lines +259 to +264
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new behavior preventing tooltips from showing when a popover (ActionMenu) is open lacks test coverage. Consider adding a system test that verifies the tooltip is hidden when a control's popover opens, and reappears after the popover closes. This is especially important given the existing comprehensive tooltip test coverage in test/system/alpha/tooltip_test.rb.

Copilot uses AI. Check for mistakes.
const isMouseLeaveFromButton =
event.type === 'mouseleave' &&
(event as MouseEvent).relatedTarget !== this.control &&
(event as MouseEvent).relatedTarget !== this
const isEscapeKeydown = event.type === 'keydown' && (event as KeyboardEvent).key === 'Escape'
const isMouseDownOnButton = event.type === 'mousedown' && event.currentTarget === this.control
const isOpeningOtherPopover = event.type === 'beforetoggle' && event.currentTarget !== this
const isOpeningOtherPopover =
event.type === 'beforetoggle' && event.currentTarget !== this && (event as ToggleEvent).newState === 'open'
const shouldHide = isMouseLeaveFromButton || isEscapeKeydown || isMouseDownOnButton || isOpeningOtherPopover

if (showing && isEscapeKeydown) {
Expand Down
Loading