|
6 | 6 | * found in the LICENSE file at https://angular.dev/license |
7 | 7 | */ |
8 | 8 |
|
9 | | -import {addAriaReferencedId, removeAriaReferencedId} from '@angular/cdk/a11y'; |
10 | 9 | import {Directionality} from '@angular/cdk/bidi'; |
11 | 10 | import {DOWN_ARROW, ENTER, ESCAPE, TAB, UP_ARROW, hasModifierKey} from '@angular/cdk/keycodes'; |
12 | 11 | import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout'; |
@@ -269,7 +268,6 @@ export class MatAutocompleteTrigger |
269 | 268 | this._componentDestroyed = true; |
270 | 269 | this._destroyPanel(); |
271 | 270 | this._closeKeyEventStream.complete(); |
272 | | - this._clearFromModal(); |
273 | 271 | } |
274 | 272 |
|
275 | 273 | /** Whether or not the autocomplete panel is open. */ |
@@ -327,11 +325,6 @@ export class MatAutocompleteTrigger |
327 | 325 | // user clicks outside. |
328 | 326 | this._changeDetectorRef.detectChanges(); |
329 | 327 | } |
330 | | - |
331 | | - // Remove aria-owns attribute when the autocomplete is no longer visible. |
332 | | - if (this._trackedModal) { |
333 | | - removeAriaReferencedId(this._trackedModal, 'aria-owns', this.autocomplete.id); |
334 | | - } |
335 | 328 | } |
336 | 329 |
|
337 | 330 | /** |
@@ -756,11 +749,6 @@ export class MatAutocompleteTrigger |
756 | 749 | private _openPanelInternal(valueOnAttach = this._element.nativeElement.value) { |
757 | 750 | this._attachOverlay(valueOnAttach); |
758 | 751 | this._floatLabel(); |
759 | | - // Add aria-owns attribute when the autocomplete becomes visible. |
760 | | - if (this._trackedModal) { |
761 | | - const panelId = this.autocomplete.id; |
762 | | - addAriaReferencedId(this._trackedModal, 'aria-owns', panelId); |
763 | | - } |
764 | 752 | } |
765 | 753 |
|
766 | 754 | private _attachOverlay(valueOnAttach: string): void { |
@@ -827,7 +815,6 @@ export class MatAutocompleteTrigger |
827 | 815 | this.autocomplete._latestOpeningTrigger = this; |
828 | 816 | this.autocomplete._setColor(this._formField?.color); |
829 | 817 | this._updatePanelState(); |
830 | | - this._applyModalPanelOwnership(); |
831 | 818 |
|
832 | 819 | // We need to do an extra `panelOpen` check in here, because the |
833 | 820 | // autocomplete won't be shown if there are no options. |
@@ -1036,66 +1023,4 @@ export class MatAutocompleteTrigger |
1036 | 1023 | } |
1037 | 1024 | } |
1038 | 1025 | } |
1039 | | - |
1040 | | - /** |
1041 | | - * Track which modal we have modified the `aria-owns` attribute of. When the combobox trigger is |
1042 | | - * inside an aria-modal, we apply aria-owns to the parent modal with the `id` of the options |
1043 | | - * panel. Track the modal we have changed so we can undo the changes on destroy. |
1044 | | - */ |
1045 | | - private _trackedModal: Element | null = null; |
1046 | | - |
1047 | | - /** |
1048 | | - * If the autocomplete trigger is inside of an `aria-modal` element, connect |
1049 | | - * that modal to the options panel with `aria-owns`. |
1050 | | - * |
1051 | | - * For some browser + screen reader combinations, when navigation is inside |
1052 | | - * of an `aria-modal` element, the screen reader treats everything outside |
1053 | | - * of that modal as hidden or invisible. |
1054 | | - * |
1055 | | - * This causes a problem when the combobox trigger is _inside_ of a modal, because the |
1056 | | - * options panel is rendered _outside_ of that modal, preventing screen reader navigation |
1057 | | - * from reaching the panel. |
1058 | | - * |
1059 | | - * We can work around this issue by applying `aria-owns` to the modal with the `id` of |
1060 | | - * the options panel. This effectively communicates to assistive technology that the |
1061 | | - * options panel is part of the same interaction as the modal. |
1062 | | - * |
1063 | | - * At time of this writing, this issue is present in VoiceOver. |
1064 | | - * See https://github.com/angular/components/issues/20694 |
1065 | | - */ |
1066 | | - private _applyModalPanelOwnership() { |
1067 | | - // TODO(http://github.com/angular/components/issues/26853): consider de-duplicating this with |
1068 | | - // the `LiveAnnouncer` and any other usages. |
1069 | | - // |
1070 | | - // Note that the selector here is limited to CDK overlays at the moment in order to reduce the |
1071 | | - // section of the DOM we need to look through. This should cover all the cases we support, but |
1072 | | - // the selector can be expanded if it turns out to be too narrow. |
1073 | | - const modal = this._element.nativeElement.closest( |
1074 | | - 'body > .cdk-overlay-container [aria-modal="true"]', |
1075 | | - ); |
1076 | | - |
1077 | | - if (!modal) { |
1078 | | - // Most commonly, the autocomplete trigger is not inside a modal. |
1079 | | - return; |
1080 | | - } |
1081 | | - |
1082 | | - const panelId = this.autocomplete.id; |
1083 | | - |
1084 | | - if (this._trackedModal) { |
1085 | | - removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId); |
1086 | | - } |
1087 | | - |
1088 | | - addAriaReferencedId(modal, 'aria-owns', panelId); |
1089 | | - this._trackedModal = modal; |
1090 | | - } |
1091 | | - |
1092 | | - /** Clears the references to the listbox overlay element from the modal it was added to. */ |
1093 | | - private _clearFromModal() { |
1094 | | - if (this._trackedModal) { |
1095 | | - const panelId = this.autocomplete.id; |
1096 | | - |
1097 | | - removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId); |
1098 | | - this._trackedModal = null; |
1099 | | - } |
1100 | | - } |
1101 | 1026 | } |
0 commit comments