@vaadin/tooltip 25.3.0-dev.1fa5a51482 → 25.3.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@
23
23
  "declarations": [
24
24
  {
25
25
  "kind": "mixin",
26
- "description": "A mixin providing linking of the tooltip content to the tooltip target\nelements using the `aria-describedby` or `aria-labelledby` attribute.",
26
+ "description": "A mixin providing linking of the tooltip content to the tooltip target\nelements using the `aria-describedby` or `aria-labelledby` attribute.\n\nTargets in the same root as the tooltip are linked by the content element\nID. ID references only resolve within a single tree scope, so targets in\nother roots are linked with ARIA element references instead.",
27
27
  "name": "TooltipAriaMixin",
28
28
  "members": [
29
29
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/tooltip",
3
- "version": "25.3.0-dev.1fa5a51482",
3
+ "version": "25.3.0-rc1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,20 +35,20 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@open-wc/dedupe-mixin": "^1.3.0",
38
- "@vaadin/a11y-base": "25.3.0-dev.1fa5a51482",
39
- "@vaadin/component-base": "25.3.0-dev.1fa5a51482",
40
- "@vaadin/markdown": "25.3.0-dev.1fa5a51482",
41
- "@vaadin/overlay": "25.3.0-dev.1fa5a51482",
42
- "@vaadin/popover": "25.3.0-dev.1fa5a51482",
43
- "@vaadin/vaadin-themable-mixin": "25.3.0-dev.1fa5a51482",
38
+ "@vaadin/a11y-base": "25.3.0-rc1",
39
+ "@vaadin/component-base": "25.3.0-rc1",
40
+ "@vaadin/markdown": "25.3.0-rc1",
41
+ "@vaadin/overlay": "25.3.0-rc1",
42
+ "@vaadin/popover": "25.3.0-rc1",
43
+ "@vaadin/vaadin-themable-mixin": "25.3.0-rc1",
44
44
  "lit": "^3.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@vaadin/aura": "25.3.0-dev.1fa5a51482",
48
- "@vaadin/chai-plugins": "25.3.0-dev.1fa5a51482",
49
- "@vaadin/test-runner-commands": "25.3.0-dev.1fa5a51482",
47
+ "@vaadin/aura": "25.3.0-rc1",
48
+ "@vaadin/chai-plugins": "25.3.0-rc1",
49
+ "@vaadin/test-runner-commands": "25.3.0-rc1",
50
50
  "@vaadin/testing-helpers": "^2.0.0",
51
- "@vaadin/vaadin-lumo-styles": "25.3.0-dev.1fa5a51482",
51
+ "@vaadin/vaadin-lumo-styles": "25.3.0-rc1",
52
52
  "sinon": "^22.0.0"
53
53
  },
54
54
  "customElements": "custom-elements.json",
@@ -56,5 +56,5 @@
56
56
  "web-types.json",
57
57
  "web-types.lit.json"
58
58
  ],
59
- "gitHead": "1cd5964b758ffbce3ddb6248a1997f55f8e0ebf6"
59
+ "gitHead": "d4809590b2f61bd607e376ab3dec84f4bfb059a7"
60
60
  }
@@ -8,6 +8,10 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
8
8
  /**
9
9
  * A mixin providing linking of the tooltip content to the tooltip target
10
10
  * elements using the `aria-describedby` or `aria-labelledby` attribute.
11
+ *
12
+ * Targets in the same root as the tooltip are linked by the content element
13
+ * ID. ID references only resolve within a single tree scope, so targets in
14
+ * other roots are linked with ARIA element references instead.
11
15
  */
12
16
  export declare function TooltipAriaMixin<T extends Constructor<HTMLElement>>(
13
17
  base: T,
@@ -3,14 +3,21 @@
3
3
  * Copyright (c) 2026 - 2026 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
6
+ import { addAriaElementReference, removeAriaElementReference } from '@vaadin/a11y-base/src/aria-element-reference.js';
7
+ import { addValuesToAttribute, removeValuesFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
7
8
 
8
9
  /**
9
10
  * A mixin providing linking of the tooltip content to the tooltip target
10
11
  * elements using the `aria-describedby` or `aria-labelledby` attribute.
12
+ *
13
+ * Targets in the same root as the tooltip are linked by the content element
14
+ * ID. ID references only resolve within a single tree scope, so targets in
15
+ * other roots are linked with ARIA element references instead.
11
16
  */
12
17
  export const TooltipAriaMixin = (superClass) =>
13
18
  class TooltipAriaMixinClass extends superClass {
19
+ #ariaReferences = [];
20
+
14
21
  static get properties() {
15
22
  return {
16
23
  /**
@@ -52,41 +59,62 @@ export const TooltipAriaMixin = (superClass) =>
52
59
  }
53
60
 
54
61
  /** @protected */
55
- updated(props) {
56
- super.updated(props);
62
+ connectedCallback() {
63
+ super.connectedCallback();
64
+ this.#addAriaReferences();
65
+ }
57
66
 
58
- const ariaTargetChanged = props.has('_effectiveAriaTarget');
59
- const ariaLinkModeChanged = props.has('ariaLinkMode');
67
+ /** @protected */
68
+ disconnectedCallback() {
69
+ super.disconnectedCallback();
70
+ this.#removeAriaReferences();
71
+ }
60
72
 
61
- if (ariaTargetChanged || ariaLinkModeChanged) {
62
- const oldTarget = ariaTargetChanged ? props.get('_effectiveAriaTarget') : this._effectiveAriaTarget;
63
- const oldMode = ariaLinkModeChanged ? props.get('ariaLinkMode') : this.ariaLinkMode;
64
- this.#removeAriaReferences(oldTarget, oldMode);
73
+ /** @protected */
74
+ updated(props) {
75
+ super.updated(props);
65
76
 
66
- const newTarget = this._effectiveAriaTarget;
67
- const newMode = this.ariaLinkMode;
68
- this.#addAriaReferences(newTarget, newMode);
77
+ if (props.has('_effectiveAriaTarget') || props.has('ariaLinkMode')) {
78
+ this.#updateAriaReferences();
69
79
  }
70
80
  }
71
81
 
72
- #addAriaReferences(target, mode) {
73
- if (!target || !mode || mode === 'none') {
82
+ #addAriaReferences() {
83
+ const mode = this.ariaLinkMode;
84
+ const targets = this._effectiveAriaTarget;
85
+ const contentNode = this.__contentNode;
86
+ if (!contentNode || !targets || !mode || mode === 'none') {
74
87
  return;
75
88
  }
76
89
 
77
- [target].flat().forEach((el) => {
78
- addValueToAttribute(el, mode, this._uniqueId);
90
+ [targets].flat().forEach((target) => {
91
+ const byReference = target.getRootNode() !== this.getRootNode();
92
+ if (byReference) {
93
+ addAriaElementReference(target, mode, contentNode);
94
+ } else {
95
+ addValuesToAttribute(target, mode, contentNode.id);
96
+ }
97
+
98
+ this.#ariaReferences.push({ target, mode, byReference });
79
99
  });
80
100
  }
81
101
 
82
- #removeAriaReferences(target, mode) {
83
- if (!target || !mode || mode === 'none') {
84
- return;
85
- }
102
+ #removeAriaReferences() {
103
+ const contentNode = this.__contentNode;
86
104
 
87
- [target].flat().forEach((el) => {
88
- removeValueFromAttribute(el, mode, this._uniqueId);
105
+ this.#ariaReferences.forEach(({ target, mode, byReference }) => {
106
+ if (byReference) {
107
+ removeAriaElementReference(target, mode, contentNode);
108
+ } else {
109
+ removeValuesFromAttribute(target, mode, contentNode.id);
110
+ }
89
111
  });
112
+ this.#ariaReferences = [];
113
+ }
114
+
115
+ #updateAriaReferences() {
116
+ this.#removeAriaReferences();
117
+ this.#addAriaReferences();
90
118
  }
91
119
 
92
120
  /** @private */
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/tooltip",
4
- "version": "25.3.0-dev.1fa5a51482",
4
+ "version": "25.3.0-rc1",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/tooltip",
4
- "version": "25.3.0-dev.1fa5a51482",
4
+ "version": "25.3.0-rc1",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {