From 27db7cf50c1be70c83ac47cc0a2c36436274c45a Mon Sep 17 00:00:00 2001 From: Zach Arend Date: Fri, 16 Jun 2023 20:31:07 +0000 Subject: [PATCH] fix(material/chips): remove button role from editable chips Removes the button role from editable input chips. Fix accessibility issue in ChipRow where the chip action element is mislabeled as a button (#27106). Fix #27106 --- src/material/chips/chip-row.html | 1 - src/material/chips/chip-row.spec.ts | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/material/chips/chip-row.html b/src/material/chips/chip-row.html index 218fdfc181d9..84d583fbe73c 100644 --- a/src/material/chips/chip-row.html +++ b/src/material/chips/chip-row.html @@ -10,7 +10,6 @@ { return chipNativeElement.querySelector('.mat-chip-edit-input')!; } - it('should set the role of the primary action based on whether it is editable', () => { + it('should set not set role of the primary action even if it is editable', () => { testComponent.editable = false; fixture.detectChanges(); expect(primaryAction.hasAttribute('role')).toBe(false); testComponent.editable = true; fixture.detectChanges(); - expect(primaryAction.getAttribute('role')).toBe('button'); + // Test regression of bug where element is mislabeled as a button role. Element that does not perform its + // action on click event is not a button by ARIA spec (#27106). + expect(primaryAction.hasAttribute('role')).toBe(false); }); it('should not delete the chip on DELETE or BACKSPACE', () => {