fix(overlays): add aria-hidden to arrow (#2030)

This commit is contained in:
Víctor Lara 2023-07-10 08:18:08 +02:00 committed by GitHub
parent b340fd7a6c
commit 5eafa1ffc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/ui': patch
---
hide overlay arrow from screen readers

2
package-lock.json generated
View file

@ -22393,7 +22393,7 @@
},
"packages/ui": {
"name": "@lion/ui",
"version": "0.3.1",
"version": "0.3.4",
"license": "MIT",
"dependencies": {
"@bundled-es-modules/message-format": "^6.0.4",

View file

@ -110,7 +110,9 @@ export const ArrowMixinImplementation = superclass =>
/** @protected */
_arrowNodeTemplate() {
return html` <div class="arrow" data-popper-arrow>${this._arrowTemplate()}</div> `;
return html`
<div class="arrow" aria-hidden="true" data-popper-arrow>${this._arrowTemplate()}</div>
`;
}
/** @protected */

View file

@ -62,6 +62,20 @@ describe('ArrowMixin', () => {
expect(window.getComputedStyle(arrowNode).getPropertyValue('display')).to.equal('block');
});
it('hides for screen readers', async () => {
const el = /** @type {ArrowTest} */ (
await fixture(html`
<arrow-test>
<div slot="content">This is a tooltip</div>
<button slot="invoker">Tooltip button</button>
</arrow-test>
`)
);
const arrowNode = /** @type {Element} */ (el._arrowNode);
expect(arrowNode.getAttribute('aria-hidden')).to.equal('true');
});
it('hides the arrow when has-arrow is false', async () => {
const el = /** @type {ArrowTest} */ (
await fixture(html`