Skip to content

feat(tooltip): add pf-v6-tooltip element#3141

Open
bennypowers wants to merge 13 commits into
staging/pfv6from
feat/tooltip/v6
Open

feat(tooltip): add pf-v6-tooltip element#3141
bennypowers wants to merge 13 commits into
staging/pfv6from
feat/tooltip/v6

Conversation

@bennypowers
Copy link
Copy Markdown
Member

Summary

  • New pf-v6-tooltip element ported from v5 with v6 design tokens
  • FloatingDOMController with arrow element positioning
  • Cancellable TooltipShowEvent/TooltipHideEvent with reason enum for selective trigger prevention
  • trigger attribute (IDREF) and property (Element ref) for external trigger elements
  • entry-delay/exit-delay (default 300ms), alignment (start/end/left/right), position, no-flip, flip-behavior
  • light-dark() CSS fallbacks for correct inverse color scheme
  • ariaDescribedByElements wiring between trigger and tooltip content
  • 9 demos: basic, placement, trigger-ref, trigger-element, slotted-content, dynamic-content, left-aligned, color-scheme, options playground
  • 17 unit tests

Test plan

  • Verify tooltip shows on hover and focus in all demos
  • Verify tooltip hides on mouseleave, focusout, and Escape
  • Verify light-dark color scheme inversion in color-scheme demo
  • Verify external trigger via IDREF (trigger-ref) and Element ref (trigger-element)
  • Verify alignment attribute changes text-align
  • Verify entry-delay/exit-delay in options playground
  • Verify no-flip disables repositioning
  • Run /review-a11y, /review-api, /review-demos
  • Visual parity with patternfly.org tooltip

Closes #3048

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: b52089b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@patternfly/elements Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

✅ Commitlint tests passed!

More Info
{
  "valid": true,
  "errors": [],
  "warnings": [],
  "input": "feat(tooltip): add pf-v6-tooltip element"
}

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Deploy Preview for patternfly-elements ready!

Name Link
🔨 Latest commit d88bd77
😎 Deploy Preview https://deploy-preview-3141--patternfly-elements.netlify.app/

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions Bot added the AT passed Automated testing has passed label May 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

SSR Test Run for 4e4a328: Report

Port tooltip to v6 design tokens and patterns.

- FloatingDOMController with arrow element positioning
- Cancellable TooltipShowEvent/TooltipHideEvent with reason enum
- `trigger` attribute (IDREF) and property (Element ref)
- `entry-delay`/`exit-delay` attributes (default 300ms)
- `alignment` attribute (start/end/left/right)
- `position`, `no-flip`, `flip-behavior` carried from v5
- `light-dark()` CSS fallbacks for inverse color scheme
- `ariaDescribedByElements` wiring on show/hide
- Escape key dismissal
- 9 demos including playground, color-scheme, and element-ref trigger
- 17 unit tests covering API, a11y, events, and cancellation

Closes #3048

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaced by pf-v6-tooltip.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

This comment has been minimized.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bennypowers bennypowers marked this pull request as ready for review May 12, 2026 11:19
@github-actions
Copy link
Copy Markdown
Contributor

SSR Test Run for 6b79b33: Report

@github-actions
Copy link
Copy Markdown
Contributor

SSR Test Run for d88bd77: Report

@bennypowers
Copy link
Copy Markdown
Member Author

bennypowers commented May 25, 2026

Cross-root aria-describedby limitation

The tooltip sets ariaDescribedByElements on the trigger to reference the shadow-internal #content div. This is the correct API for cross-root ARIA relationships, but it silently fails in all browsers today: the accessibility tree shows no describedby relationship.

Per the current spec, ARIA element reflection only works when shadow roots are in an ancestor/descendant relationship, and even then only in the shadow-to-light direction. Our use case (light DOM trigger referencing shadow DOM content) goes the wrong way. The WPT test explicitly asserts that cross-root refs produce an empty computed label.

This means tooltip triggers currently have no programmatic describedby relationship in any browser. The tooltip content is still announced when visible (via role="tooltip" and proximity in the accessibility tree), but there is no formal ARIA association.

The Reference Target proposal (Chrome origin trial) would solve the slotted trigger case. The external trigger case (sibling elements) would need the relaxation discussed in WICG/aom#192. Both whatwg/html#5401 and whatwg/html#10707 track the broader spec work.

Keeping the ariaDescribedByElements call as progressive enhancement -- it will start working once browsers ship a solution. No workaround attempted; the alternatives (hidden light DOM spans, aria-label mirroring) add complexity for a temporary gap.

@adamjohnson and @hellogreg -- could you verify the actual screen reader experience here? Want to confirm the tooltip content is still announced via proximity/role="tooltip" even without the formal describedby association.

- Static document keydown listener for Escape (works with external triggers)
- Screen reader announcer via static `role="status"` live region
- `silent` attribute to opt out of announcements
- Remove physical `'left'`/`'right'` from `TooltipAlignment`, keep logical
  `'start'`/`'end'` only
- Remove `color-scheme: light dark` from `:host` so tooltip inherits
  container scheme and inverts correctly via `light-dark()`
- Fix `user-select: initial` to `auto`
- Why-comments on `ariaDescribedByElements` cross-root limitation
  and intentional bidirectional `visible` state
- Improved JSDoc for cem health (66 -> 85): element description,
  slot a11y notes, CSS token refs, event detail shapes, added missing
  `--pf-v6-c-tooltip__arrow--BoxShadow` `@cssprop`

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- hide event firing and reason
- focusin/focusout triggers
- Element reference trigger property
- flip-behavior attribute parsing
- visible attribute (declarative)
- slot overrides content attribute
- cancel hide event
- Escape key with external trigger (document listener)
- silent attribute

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Demonstrate feature parity with React trigger modes using cancelable
show/hide events:
- click-trigger: click-to-toggle tooltip via preventDefault on hover
- manual-trigger: checkbox-controlled tooltip via preventDefault on
  both hover and focus triggers

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Not a standalone demo on patternfly.org; alignment is covered by the
options playground demo.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add static live-region announcer pattern for tooltip/popover content
  (from rh-tooltip)
- Update cross-root ARIA section with WPT test link and spec references
  (WICG/aom#192, whatwg/html#5401, WICG/webcomponents#1086)

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AT passed Automated testing has passed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant