Skip to content

Commit f3ce925

Browse files
committed
fix(cdk-experimental/popover-edit): Fix dialog role and allow aria label on popup
1 parent 1f992d0 commit f3ce925

File tree

6 files changed

+100
-5
lines changed

6 files changed

+100
-5
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@
6464
"@angular/platform-browser": "^18.1.0-next.3",
6565
"@types/google.maps": "^3.54.10",
6666
"@types/youtube": "^0.0.50",
67+
"babel-plugin-istanbul": "^6.1.1",
68+
"regjsgen": "^0.8.0",
6769
"rxjs": "^6.6.7",
6870
"rxjs-tslint-rules": "^4.34.8",
71+
"text-table": "^0.2.0",
6972
"tslib": "^2.3.1",
7073
"zone.js": "~0.14.0"
7174
},
@@ -74,8 +77,8 @@
7477
"@angular-devkit/core": "^18.1.0-next.3",
7578
"@angular-devkit/schematics": "^18.1.0-next.3",
7679
"@angular/bazel": "https://github.com/angular/bazel-builds.git#bac9c1abe1e6ac1801fbbccb53353a1ed7126469",
77-
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#74e0e7b090c6e16056290836b2d936ca7820b86f",
7880
"@angular/build": "^18.1.0-next.3",
81+
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#74e0e7b090c6e16056290836b2d936ca7820b86f",
7982
"@angular/cli": "^18.1.0-next.3",
8083
"@angular/compiler-cli": "^18.1.0-next.3",
8184
"@angular/localize": "^18.1.0-next.3",
@@ -142,8 +145,8 @@
142145
"@material/tab-scroller": "15.0.0-canary.7f224ddd4.0",
143146
"@material/textfield": "15.0.0-canary.7f224ddd4.0",
144147
"@material/theme": "15.0.0-canary.7f224ddd4.0",
145-
"@material/tooltip": "15.0.0-canary.7f224ddd4.0",
146148
"@material/tokens": "15.0.0-canary.7f224ddd4.0",
149+
"@material/tooltip": "15.0.0-canary.7f224ddd4.0",
147150
"@material/top-app-bar": "15.0.0-canary.7f224ddd4.0",
148151
"@material/touch-target": "15.0.0-canary.7f224ddd4.0",
149152
"@material/typography": "15.0.0-canary.7f224ddd4.0",

src/cdk-experimental/popover-edit/popover-edit.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const POPOVER_EDIT_DIRECTIVE_NAME = `
6262
[cdkPopoverEdit]="nameEdit"
6363
[cdkPopoverEditColspan]="colspan"
6464
[cdkPopoverEditDisabled]="nameEditDisabled"
65+
[cdkPopoverEditAriaLabel]="nameEditAriaLabel"
6566
`;
6667

6768
const POPOVER_EDIT_DIRECTIVE_WEIGHT = `[cdkPopoverEdit]="weightEdit" cdkPopoverEditTabOut`;
@@ -77,6 +78,7 @@ abstract class BaseTestComponent {
7778

7879
preservedValues = new FormValueContainer<PeriodicElement, {'name': string}>();
7980
nameEditDisabled = false;
81+
nameEditAriaLabel: string | undefined = undefined;
8082
ignoreSubmitUnlessValid = true;
8183
clickOutBehavior: PopoverEditClickOutBehavior = 'close';
8284
colspan: CdkPopoverEditColspan = {};
@@ -557,6 +559,22 @@ describe('CDK Popover Edit', () => {
557559
expect(component.lensIsOpen()).toBe(false);
558560
clearLeftoverTimers();
559561
}));
562+
563+
it('sets aria label and role dialog on the popup', fakeAsync(() => {
564+
component.nameEditAriaLabel = 'Label of name!!';
565+
fixture.changeDetectorRef.markForCheck();
566+
fixture.detectChanges();
567+
568+
// Uses Enter to open the lens.
569+
component.openLens();
570+
fixture.detectChanges();
571+
572+
expect(component.lensIsOpen()).toBe(true);
573+
const dialogElem = component.getEditPane()!;
574+
expect(dialogElem.getAttribute('aria-label')).toBe('Label of name!!');
575+
expect(dialogElem.getAttribute('role')).toBe('dialog');
576+
clearLeftoverTimers();
577+
}));
560578
});
561579

562580
describe('focus manipulation', () => {

src/cdk-experimental/popover-edit/table-directives.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ const POPOVER_EDIT_INPUTS = [
173173
{name: 'context', alias: 'cdkPopoverEditContext'},
174174
{name: 'colspan', alias: 'cdkPopoverEditColspan'},
175175
{name: 'disabled', alias: 'cdkPopoverEditDisabled'},
176+
{name: 'ariaLabel', alias: 'cdkPopoverEditAriaLabel'},
176177
];
177178

178179
/**
@@ -196,6 +197,9 @@ export class CdkPopoverEdit<C> implements AfterViewInit, OnDestroy {
196197
*/
197198
context?: C;
198199

200+
/** Aria label to set on the popover dialog element. */
201+
ariaLabel?: string;
202+
199203
/**
200204
* Specifies that the popup should cover additional table cells before and/or after
201205
* this one.
@@ -302,7 +306,10 @@ export class CdkPopoverEdit<C> implements AfterViewInit, OnDestroy {
302306
});
303307

304308
this.initFocusTrap();
305-
this.overlayRef.overlayElement.setAttribute('aria-role', 'dialog');
309+
this.overlayRef.overlayElement.setAttribute('role', 'dialog');
310+
if (this.ariaLabel) {
311+
this.overlayRef.overlayElement.setAttribute('aria-label', this.ariaLabel);
312+
}
306313

307314
this.overlayRef.detachments().subscribe(() => this.closeEditOverlay());
308315
}

src/material-experimental/popover-edit/popover-edit.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const POPOVER_EDIT_DIRECTIVE_NAME = `
5353
[matPopoverEdit]="nameEdit"
5454
[matPopoverEditColspan]="colspan"
5555
[matPopoverEditDisabled]="nameEditDisabled"
56+
[matPopoverEditAriaLabel]="nameEditAriaLabel"
5657
`;
5758

5859
const POPOVER_EDIT_DIRECTIVE_WEIGHT = `[matPopoverEdit]="weightEdit" matPopoverEditTabOut`;
@@ -69,6 +70,7 @@ abstract class BaseTestComponent {
6970
preservedValues = new FormValueContainer<PeriodicElement, {'name': string}>();
7071

7172
nameEditDisabled = false;
73+
nameEditAriaLabel: string | undefined = undefined;
7274
ignoreSubmitUnlessValid = true;
7375
clickOutBehavior: PopoverEditClickOutBehavior = 'close';
7476
colspan: CdkPopoverEditColspan = {};
@@ -430,6 +432,22 @@ describe('Material Popover Edit', () => {
430432
expect(component.lensIsOpen()).toBe(false);
431433
clearLeftoverTimers();
432434
}));
435+
436+
it('sets aria label and role dialog on the popup', fakeAsync(() => {
437+
component.nameEditAriaLabel = 'Label of name!!';
438+
fixture.changeDetectorRef.markForCheck();
439+
fixture.detectChanges();
440+
441+
// Uses Enter to open the lens.
442+
component.openLens();
443+
fixture.detectChanges();
444+
445+
expect(component.lensIsOpen()).toBe(true);
446+
const dialogElem = component.getEditPane()!;
447+
expect(dialogElem.getAttribute('aria-label')).toBe('Label of name!!');
448+
expect(dialogElem.getAttribute('role')).toBe('dialog');
449+
clearLeftoverTimers();
450+
}));
433451
});
434452

435453
describe('focus manipulation', () => {

src/material-experimental/popover-edit/table-directives.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const POPOVER_EDIT_INPUTS = [
2626
{name: 'context', alias: 'matPopoverEditContext'},
2727
{name: 'colspan', alias: 'matPopoverEditColspan'},
2828
{name: 'disabled', alias: 'matPopoverEditDisabled'},
29+
{name: 'ariaLabel', alias: 'matPopoverEditAriaLabel'},
2930
];
3031

3132
const EDIT_PANE_CLASS = 'mat-edit-pane';

yarn.lock

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@
433433
json5 "^2.2.3"
434434
semver "^6.3.1"
435435

436-
"@babel/[email protected]", "@babel/core@^7.16.0", "@babel/core@^7.16.12", "@babel/core@^7.23.9":
436+
"@babel/[email protected]", "@babel/core@^7.12.3", "@babel/core@^7.16.0", "@babel/core@^7.16.12", "@babel/core@^7.23.9":
437437
version "7.24.7"
438438
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.24.7.tgz#b676450141e0b52a3d43bc91da86aa608f950ac4"
439439
integrity sha512-nykK+LEK86ahTkX/3TgauT0ikKoNCfKHEaZYTUVupJdTLzGNvrblu4u6fa7DhZONAltdf8e662t/abY8idrd/g==
@@ -691,7 +691,7 @@
691691
js-tokens "^4.0.0"
692692
picocolors "^1.0.0"
693693

694-
"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.10.3", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.24.6", "@babel/parser@^7.24.7":
694+
"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.10.3", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.24.6", "@babel/parser@^7.24.7":
695695
version "7.24.7"
696696
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.24.7.tgz#9a5226f92f0c5c8ead550b750f5608e766c8ce85"
697697
integrity sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw==
@@ -2195,6 +2195,17 @@
21952195
wrap-ansi "^8.1.0"
21962196
wrap-ansi-cjs "npm:wrap-ansi@^7.0.0"
21972197

2198+
"@istanbuljs/load-nyc-config@^1.0.0":
2199+
version "1.1.0"
2200+
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
2201+
integrity sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==
2202+
dependencies:
2203+
camelcase "^5.3.1"
2204+
find-up "^4.1.0"
2205+
get-package-type "^0.1.0"
2206+
js-yaml "^3.13.1"
2207+
resolve-from "^5.0.0"
2208+
21982209
"@istanbuljs/schema@^0.1.2", "@istanbuljs/schema@^0.1.3":
21992210
version "0.1.3"
22002211
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98"
@@ -5092,6 +5103,17 @@ [email protected]:
50925103
find-cache-dir "^4.0.0"
50935104
schema-utils "^4.0.0"
50945105

5106+
babel-plugin-istanbul@^6.1.1:
5107+
version "6.1.1"
5108+
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz#fa88ec59232fd9b4e36dbbc540a8ec9a9b47da73"
5109+
integrity sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==
5110+
dependencies:
5111+
"@babel/helper-plugin-utils" "^7.0.0"
5112+
"@istanbuljs/load-nyc-config" "^1.0.0"
5113+
"@istanbuljs/schema" "^0.1.2"
5114+
istanbul-lib-instrument "^5.0.4"
5115+
test-exclude "^6.0.0"
5116+
50955117
babel-plugin-polyfill-corejs2@^0.4.10:
50965118
version "0.4.11"
50975119
resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.11.tgz#30320dfe3ffe1a336c15afdcdafd6fd615b25e33"
@@ -8767,6 +8789,11 @@ get-own-enumerable-property-symbols@^3.0.0:
87678789
resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz#b5fde77f22cbe35f390b4e089922c50bce6ef664"
87688790
integrity sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==
87698791

8792+
get-package-type@^0.1.0:
8793+
version "0.1.0"
8794+
resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a"
8795+
integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==
8796+
87708797
get-port@^5.1.1:
87718798
version "5.1.1"
87728799
resolved "https://registry.yarnpkg.com/get-port/-/get-port-5.1.1.tgz#0469ed07563479de6efb986baf053dcd7d4e3193"
@@ -10252,6 +10279,17 @@ [email protected]:
1025210279
istanbul-lib-coverage "^3.2.0"
1025310280
semver "^7.5.4"
1025410281

10282+
istanbul-lib-instrument@^5.0.4:
10283+
version "5.2.1"
10284+
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz#d10c8885c2125574e1c231cacadf955675e1ce3d"
10285+
integrity sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==
10286+
dependencies:
10287+
"@babel/core" "^7.12.3"
10288+
"@babel/parser" "^7.14.7"
10289+
"@istanbuljs/schema" "^0.1.2"
10290+
istanbul-lib-coverage "^3.2.0"
10291+
semver "^6.3.0"
10292+
1025510293
istanbul-lib-report@^3.0.0:
1025610294
version "3.0.1"
1025710295
resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d"
@@ -13580,6 +13618,11 @@ registry-url@^5.0.0:
1358013618
dependencies:
1358113619
rc "^1.2.8"
1358213620

13621+
regjsgen@^0.8.0:
13622+
version "0.8.0"
13623+
resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.8.0.tgz#df23ff26e0c5b300a6470cad160a9d090c3a37ab"
13624+
integrity sha512-RvwtGe3d7LvWiDQXeQw8p5asZUmfU1G/l6WbUXeHta7Y2PEIvBTwH6E2EfmYUK8pxcxEdEmaomqyp0vZZ7C+3Q==
13625+
1358313626
regjsparser@^0.9.1:
1358413627
version "0.9.1"
1358513628
resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.9.1.tgz#272d05aa10c7c1f67095b1ff0addae8442fc5709"
@@ -15348,6 +15391,11 @@ [email protected]:
1534815391
resolved "https://registry.yarnpkg.com/text-hex/-/text-hex-1.0.0.tgz#69dc9c1b17446ee79a92bf5b884bb4b9127506f5"
1534915392
integrity sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==
1535015393

15394+
text-table@^0.2.0:
15395+
version "0.2.0"
15396+
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
15397+
integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==
15398+
1535115399
tfunk@^4.0.0:
1535215400
version "4.0.0"
1535315401
resolved "https://registry.yarnpkg.com/tfunk/-/tfunk-4.0.0.tgz#de9399feaf2060901d590b7faad80fcd5443077e"

0 commit comments

Comments
 (0)