Merge pull request #2356 from ing-bank/fix/overlay-is-modal

fix: clean code for overlay isModal
This commit is contained in:
Oleksii Kadurin 2024-08-28 13:39:53 +02:00 committed by GitHub
commit c6a8d6d754
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -640,7 +640,7 @@ export class OverlayController extends EventTarget {
__setupTeardownAccessibility({ phase }) { __setupTeardownAccessibility({ phase }) {
if (phase === 'init') { if (phase === 'init') {
this.__storeOriginalAttrs(this.contentNode, ['role', 'id']); this.__storeOriginalAttrs(this.contentNode, ['role', 'id']);
const isModal = this.hasBackdrop; const isModal = this.trapsKeyboardFocus;
if (this.invokerNode) { if (this.invokerNode) {
const attributesToStore = ['aria-labelledby', 'aria-describedby']; const attributesToStore = ['aria-labelledby', 'aria-describedby'];
@ -1300,7 +1300,7 @@ export class OverlayController extends EventTarget {
if (phase === 'init' || phase === 'teardown') { if (phase === 'init' || phase === 'teardown') {
this.__setupTeardownAccessibility({ phase }); this.__setupTeardownAccessibility({ phase });
} }
const isModal = this.hasBackdrop; const isModal = this.trapsKeyboardFocus;
if (this.invokerNode && !this.isTooltip && !isModal) { if (this.invokerNode && !this.isTooltip && !isModal) {
this.invokerNode.setAttribute('aria-expanded', `${phase === 'show'}`); this.invokerNode.setAttribute('aria-expanded', `${phase === 'show'}`);
} }

View file

@ -1534,7 +1534,7 @@ describe('OverlayController', () => {
); );
const ctrl = new OverlayController({ const ctrl = new OverlayController({
...withLocalTestConfig(), ...withLocalTestConfig(),
hasBackdrop: true, trapsKeyboardFocus: true,
handlesAccessibility: true, handlesAccessibility: true,
invokerNode, invokerNode,
}); });