Skip to content

Commit afd8d0a

Browse files
authored
Merge pull request #3141 from patternfly/feat/tooltip/v6
feat(tooltip)!: port to `pf-v6-tooltip`
2 parents 02103f4 + 63dcf62 commit afd8d0a

39 files changed

Lines changed: 1828 additions & 1102 deletions

‎.changeset/keen-newts-fly.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
"@patternfly/elements": major
3+
---
4+
5+
Added `<pf-v6-tooltip>` replacing `<pf-v5-tooltip>`. Tooltip now follows
6+
PatternFly v6 design specs.
7+
8+
```html
9+
<pf-v6-tooltip content="Copy to clipboard">
10+
<button>Copy</button>
11+
</pf-v6-tooltip>
12+
```
13+
14+
**Breaking changes from v5:**
15+
16+
- Tag name changed from `pf-v5-tooltip` to `pf-v6-tooltip`
17+
- `visible` attribute replaces programmatic-only visibility
18+
- `entry-delay` and `exit-delay` attributes added (300ms default)
19+
- `alignment` attribute replaces `isContentLeftAligned` (accepts `start`/`end`)
20+
- `no-flip` inverted boolean replaces `enableFlip`
21+
- `content` slot added for rich HTML content
22+
- Cancelable `show`/`hide` events with `reason` property
23+
- `silent` attribute for suppressing screen reader announcements
24+
- CSS custom properties replace inline style props (`maxWidth`, etc.)
25+
26+
Users who need the react component's `trigger` prop are advised to use `<pf-v6-popover>` instead, or to use the cancellable `show`/`hide` events to prevent default behaviour.

‎.claude/ADVICE.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,13 @@ Icons are decorative or informational, not interactive. Click handlers belong on
641641

642642
> "You must not add click listeners to icons." (PFE PR #2951)
643643
644+
### Use a static live-region announcer for tooltip/popover content
645+
Tooltip and popover content lives in shadow DOM, which prevents `aria-describedby` from working cross-root. Use a shared static `role="status"` announcer element (visually hidden, appended to `document.body`) to announce content to screen readers. Announce on show, clear on hide. Provide a `silent` boolean attribute to opt out when authors provide their own accessible label.
646+
647+
> Pattern established in `rh-tooltip` (RHDS): static `initAnnouncer()` + `announce(text)` in `show()`, clear in `hide()`. Adopted in `pf-v6-tooltip` (PFE).
648+
644649
### Consider cross-root ARIA limitations
645-
When composing elements across shadow boundaries, cross-root ARIA references don't work declaratively yet. This may require duplicating internal elements as a workaround. Client-side, ARIA IDL DOM properties (baseline 2025) can resolve cross-root references imperatively via JavaScript. Upcoming APIs like Reference Target will provide declarative solutions.
650+
When composing elements across shadow boundaries, cross-root ARIA references don't work declaratively yet. `ariaDescribedByElements` and similar IDL properties silently fail for light-to-shadow references. The [WPT test](https://github.com/web-platform-tests/wpt/blob/master/custom-elements/element-internals-aria-element-reflection.html) explicitly asserts cross-root refs produce an empty computed label. See also [WICG/aom#192](https://github.com/WICG/aom/issues/192) and [whatwg/html#5401](https://github.com/whatwg/html/issues/5401). Upcoming APIs like Reference Target ([WICG/webcomponents#1086](https://github.com/WICG/webcomponents/issues/1086)) will provide solutions. Keep cross-root IDL assignments as progressive enhancement.
646651

647652
> "We can't use pf-button until browser vendors ship a solution for x-root aria." (PFE PR #2676)
648653

‎.github/workflows/tests.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,13 @@ jobs:
9797
ssr:
9898
name: SSR Tests (Playwright)
9999
runs-on: ubuntu-latest
100+
# --ipc=host gives Chromium the host's shared memory namespace.
101+
# Without it, fullPage screenshots can hang when the compositor
102+
# exhausts Docker's default 64 MB /dev/shm.
103+
# https://playwright.dev/docs/docker#shared-memory-size
100104
container:
101105
image: mcr.microsoft.com/playwright:v1.57.0-noble
106+
options: --ipc=host
102107
steps:
103108
- uses: actions/checkout@v4
104109
- uses: actions/setup-node@v4

‎docs/framework-integration/react.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ tags:
132132
import { Card } from "@patternfly/elements/react/pf-v5-card/pf-v5-card.js";
133133
import { Switch } from "@patternfly/elements/react/pf-v6-switch/pf-v6-switch.js";
134134
import { Popover } from "@patternfly/elements/react/pf-v5-popover/pf-v5-popover.js";
135-
import { Tooltip } from "@patternfly/elements/react/pf-v5-tooltip/pf-v5-tooltip.js";
135+
import { Tooltip } from "@patternfly/elements/react/pf-v6-tooltip/pf-v6-tooltip.js";
136136

137137
import "./App.css";
138138
```
@@ -208,7 +208,7 @@ tags:
208208
### Tooltip
209209
210210
Now we have a card, button, and switch component, let's add
211-
[`pf-v5-tooltip`][pf-v5-tooltip] web component in our app. We will show the tooltip
211+
[`pf-v6-tooltip`][pf-v6-tooltip] web component in our app. We will show the tooltip
212212
text on mouseover.
213213
214214
```js
@@ -356,7 +356,7 @@ tags:
356356
[pf-v5-button]: https://patternflyelements.org/components/button/
357357
[pf-v5-card]: https://patternflyelements.org/components/card/
358358
[pf-v6-switch]: https://patternflyelements.org/components/switch/
359-
[pf-v5-tooltip]: https://patternflyelements.org/components/tooltip/
359+
[pf-v6-tooltip]: https://patternflyelements.org/components/tooltip/
360360
[pf-v5-popover]: https://patternflyelements.org/components/popover/
361361
[inng]: https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-angular-app-4b18b1c9c363
362362
[invue]: https://patternflyelements.org/framework-integration/vue/

‎elements/pf-v5-chip/demo/long-chip-with-tooltip.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<pf-v5-tooltip>
1+
<pf-v6-tooltip>
22
<pf-v5-chip id="longchip">Really long chip that goes on and on</pf-v5-chip>
33
<span slot="content">Really long chip that goes on and on</span>
4-
</pf-v5-tooltip>
4+
</pf-v6-tooltip>
55

66
<style>
77
#longchip::part(text) {
@@ -16,6 +16,6 @@
1616

1717
<script type="module">
1818
import '@patternfly/elements/pf-v5-chip/pf-v5-chip.js';
19-
import '@patternfly/elements/pf-v5-tooltip/pf-v5-tooltip.js';
19+
import '@patternfly/elements/pf-v6-tooltip/pf-v6-tooltip.js';
2020
</script>
2121

‎elements/pf-v5-chip/docs/pf-v5-chip.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script type="module">
22
import '@patternfly/elements/pf-v5-icon/pf-v5-icon.js';
33
import '@patternfly/elements/pf-v6-badge/pf-v6-badge.js';
4-
import '@patternfly/elements/pf-v5-tooltip/pf-v5-tooltip.js';
4+
import '@patternfly/elements/pf-v6-tooltip/pf-v6-tooltip.js';
55
</script>
66

77
{% renderOverview %}
@@ -36,12 +36,12 @@ Chips can be removable or read-only. The Overflow chip is a special chip that is
3636
#### Max-width
3737

3838
{% htmlexample %}
39-
<pf-v5-tooltip id="max"
39+
<pf-v6-tooltip id="max"
4040
position="top">
4141
<pf-v5-chip onclick="this.parentElement.remove()"
4242
style="max-width:10em;">Really long chip that goes on and on</pf-v5-chip>
4343
<span slot="content">Really long chip that goes on and on</span>
44-
</pf-v5-tooltip>
44+
</pf-v6-tooltip>
4545
{% endhtmlexample %}
4646

4747
### Chip group

‎elements/pf-v5-clipboard-copy/pf-v5-clipboard-copy.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import formControlStyles from '../form-control.css';
99

1010
import '@patternfly/elements/pf-v5-button/pf-v5-button.js';
1111
import '@patternfly/elements/pf-v5-icon/pf-v5-icon.js';
12-
import '@patternfly/elements/pf-v5-tooltip/pf-v5-tooltip.js';
12+
import '@patternfly/elements/pf-v6-tooltip/pf-v6-tooltip.js';
1313

1414
const sleep = (ms?: number) => new Promise(r => setTimeout(r, ms));
1515

@@ -112,7 +112,7 @@ export class PfV5ClipboardCopy extends LitElement {
112112
?disabled="${expanded || readonly}"
113113
.value="${this.value}"
114114
@input="${this.#onChange}">
115-
<pf-v5-tooltip>
115+
<pf-v6-tooltip>
116116
<pf-v5-button id="copy-button"
117117
icon="copy"
118118
?plain="${inline || compact}"
@@ -121,7 +121,7 @@ export class PfV5ClipboardCopy extends LitElement {
121121
@click="${this.copy}">
122122
</pf-v5-button>
123123
<span slot="content">${this.#copied ? this.clickTip : this.hoverTip}</span>
124-
</pf-v5-tooltip>
124+
</pf-v6-tooltip>
125125
<!-- Place additional action buttons here -->
126126
<slot name="actions"></slot>
127127
</div>

‎elements/pf-v5-icon/demo/sets.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1>Default Icon Sets</h1>
1313

1414
<script type="module">
1515
import '@patternfly/elements/pf-v5-icon/pf-v5-icon.js';
16-
import '@patternfly/elements/pf-v5-tooltip/pf-v5-tooltip.js';
16+
import '@patternfly/elements/pf-v6-tooltip/pf-v6-tooltip.js';
1717

1818
import { render, html } from 'lit';
1919
import { repeat } from 'lit/directives/repeat.js';

‎elements/pf-v5-tooltip/README.md‎

Lines changed: 0 additions & 64 deletions
This file was deleted.

‎elements/pf-v5-tooltip/demo/block-triggers.html‎

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)