Skip to content

Commit

Permalink
Revert "fix: add aria-expanded attribute only for the non-modal dialogs"
Browse files Browse the repository at this point in the history
This reverts commit fa832d9.
  • Loading branch information
okadurin committed Aug 27, 2024
1 parent fa832d9 commit 5f92a72
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 39 deletions.
5 changes: 0 additions & 5 deletions .changeset/olive-mirrors-grab.md

This file was deleted.

22 changes: 1 addition & 21 deletions packages/ui/components/dialog/test/lion-dialog.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable lit-a11y/no-autofocus */
import { expect, fixture as _fixture, html, unsafeStatic, aTimeout } from '@open-wc/testing';
import { expect, fixture as _fixture, html, unsafeStatic } from '@open-wc/testing';
import { runOverlayMixinSuite } from '../../overlays/test-suites/OverlayMixin.suite.js';
import '@lion/ui/define/lion-dialog.js';

Expand Down Expand Up @@ -166,24 +166,4 @@ describe('lion-dialog', () => {
el.setAttribute('opened', '');
});
});

describe('Accessibility', () => {
it('adds [aria-expanded] to invoker button', async () => {
const el = await fixture(
html` <lion-dialog>
<div slot="content" class="dialog">Hey there</div>
<button slot="invoker">Popup button</button>
</lion-dialog>`,
);
const invokerButton = /** @type {HTMLElement} */ (el.querySelector('[slot="invoker"]'));

expect(invokerButton.getAttribute('aria-expanded')).to.equal(null);
await invokerButton.click();
await aTimeout(0);
expect(invokerButton.getAttribute('aria-expanded')).to.equal(null);
await invokerButton.click();
await aTimeout(0);
expect(invokerButton.getAttribute('aria-expanded')).to.equal(null);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,11 @@ describe('<lion-input-datepicker>', () => {
const el = await fixture(html`<lion-input-datepicker></lion-input-datepicker>`);
const elObj = new DatepickerInputObject(el);

expect(elObj.invokerEl.getAttribute('aria-expanded')).to.equal(null);
expect(elObj.invokerEl.getAttribute('aria-expanded')).to.equal('false');
await elObj.openCalendar();
expect(elObj.invokerEl.getAttribute('aria-expanded')).to.equal(null);
expect(elObj.invokerEl.getAttribute('aria-expanded')).to.equal('true');
await elObj.closeCalendar();
expect(elObj.invokerEl.getAttribute('aria-expanded')).to.equal(null);
expect(elObj.invokerEl.getAttribute('aria-expanded')).to.equal('false');
});

it('is accessible when closed', async () => {
Expand Down
18 changes: 8 additions & 10 deletions packages/ui/components/overlays/src/OverlayController.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,13 @@ export class OverlayController extends EventTarget {
__setupTeardownAccessibility({ phase }) {
if (phase === 'init') {
this.__storeOriginalAttrs(this.contentNode, ['role', 'id']);
const isModal = this.hasBackdrop;

if (this.invokerNode) {
const attributesToStore = ['aria-labelledby', 'aria-describedby'];
if (!isModal) {
attributesToStore.push('aria-expanded');
}
this.__storeOriginalAttrs(this.invokerNode, attributesToStore);
this.__storeOriginalAttrs(this.invokerNode, [
'aria-expanded',
'aria-labelledby',
'aria-describedby',
]);
}

if (!this.contentNode.id) {
Expand All @@ -662,7 +661,7 @@ export class OverlayController extends EventTarget {
}
this.contentNode.setAttribute('role', 'tooltip');
} else {
if (this.invokerNode && !isModal) {
if (this.invokerNode) {
this.invokerNode.setAttribute('aria-expanded', `${this.isShown}`);
}
if (!this.contentNode.getAttribute('role')) {
Expand Down Expand Up @@ -1093,7 +1092,7 @@ export class OverlayController extends EventTarget {
// @ts-ignore
this.__wrappingDialogNode.close();
// @ts-ignore
this.__wrappingDialogNode.show();
this.__wrappingDialogNode.showModal();
}
// else {
this.enableTrapsKeyboardFocus();
Expand Down Expand Up @@ -1300,8 +1299,7 @@ export class OverlayController extends EventTarget {
if (phase === 'init' || phase === 'teardown') {
this.__setupTeardownAccessibility({ phase });
}
const isModal = this.hasBackdrop;
if (this.invokerNode && !this.isTooltip && !isModal) {
if (this.invokerNode && !this.isTooltip) {
this.invokerNode.setAttribute('aria-expanded', `${phase === 'show'}`);
}
}
Expand Down

0 comments on commit 5f92a72

Please sign in to comment.