Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add overlayRole property to customize dialog role #7582

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/dialog/src/vaadin-dialog-base-mixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ export declare class DialogBaseMixinClass {
* Set to true to remove backdrop and allow click events on background elements.
*/
modeless: boolean;

/**
* The `role` attribute value to be set on the overlay. Defaults to "dialog".
*
* @attr {string} overlay-role
*/
overlayRole: string;
}
10 changes: 10 additions & 0 deletions packages/dialog/src/vaadin-dialog-base-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export const DialogBaseMixin = (superClass) =>
type: Boolean,
value: false,
},

/**
* The `role` attribute value to be set on the overlay. Defaults to "dialog".
*
* @attr {string} overlay-role
*/
overlayRole: {
type: String,
value: 'dialog',
},
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/dialog/src/vaadin-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Dialog extends DialogDraggableMixin(

<vaadin-dialog-overlay
id="overlay"
role="dialog"
role$="[[overlayRole]]"
header-title="[[headerTitle]]"
on-opened-changed="_onOverlayOpened"
on-mousedown="_bringOverlayToFront"
Expand Down
2 changes: 1 addition & 1 deletion packages/dialog/src/vaadin-lit-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Dialog extends DialogDraggableMixin(
return html`
<vaadin-dialog-overlay
id="overlay"
role="dialog"
role="${this.overlayRole}"
.owner="${this}"
.opened="${this.opened}"
.headerTitle="${this.headerTitle}"
Expand Down
14 changes: 14 additions & 0 deletions packages/dialog/test/dom/__snapshots__/dialog.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,17 @@ snapshots["vaadin-dialog overlay class"] =
`;
/* end snapshot vaadin-dialog overlay class */

snapshots["vaadin-dialog overlay role"] =
`<vaadin-dialog-overlay
focus-trap=""
id="overlay"
opened=""
restore-focus-on-close=""
role="alertdialog"
with-backdrop=""
>
content
</vaadin-dialog-overlay>
`;
/* end snapshot vaadin-dialog overlay role */

5 changes: 5 additions & 0 deletions packages/dialog/test/dom/dialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ describe('vaadin-dialog', () => {
dialog.overlayClass = 'custom dialog-overlay';
await expect(overlay).dom.to.equalSnapshot(SNAPSHOT_CONFIG);
});

it('overlay role', async () => {
dialog.overlayRole = 'alertdialog';
await expect(overlay).dom.to.equalSnapshot(SNAPSHOT_CONFIG);
});
});
1 change: 1 addition & 0 deletions packages/dialog/test/typings/dialog.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ assertType<boolean>(dialog.resizable);
assertType<boolean>(dialog.noCloseOnEsc);
assertType<boolean>(dialog.noCloseOnOutsideClick);
assertType<string>(dialog.overlayClass);
assertType<string>(dialog.overlayRole);
assertType<string | null | undefined>(dialog.headerTitle);
assertType<DialogRenderer | null | undefined>(dialog.renderer);
assertType<DialogRenderer | null | undefined>(dialog.headerRenderer);
Expand Down
Loading