mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 14:13:37 +08:00
A11Y: correctly sets role=dialog and aria-labelledby for d-modals (#11850)
This commit is contained in:
parent
3c028cb67f
commit
1989a326c9
|
@ -1,3 +1,4 @@
|
|||
import { computed } from "@ember/object";
|
||||
import Component from "@ember/component";
|
||||
import I18n from "I18n";
|
||||
import afterTransition from "discourse/lib/after-transition";
|
||||
|
@ -12,10 +13,16 @@ export default Component.extend({
|
|||
"modalStyle",
|
||||
"hasPanels",
|
||||
],
|
||||
attributeBindings: ["data-keyboard", "aria-modal"],
|
||||
attributeBindings: [
|
||||
"data-keyboard",
|
||||
"aria-modal",
|
||||
"role",
|
||||
"ariaLabelledby:aria-labelledby",
|
||||
],
|
||||
dismissable: true,
|
||||
title: null,
|
||||
subtitle: null,
|
||||
role: "dialog",
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
@ -33,6 +40,10 @@ export default Component.extend({
|
|||
// Inform screenreaders of the modal
|
||||
"aria-modal": "true",
|
||||
|
||||
ariaLabelledby: computed("title", function () {
|
||||
return this.title ? "discourse-modal-title" : null;
|
||||
}),
|
||||
|
||||
@on("didInsertElement")
|
||||
setUp() {
|
||||
$("html").on("keyup.discourse-modal", (e) => {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
{{#if title}}
|
||||
<div class="title">
|
||||
<h3>{{title}}</h3>
|
||||
<h3 id="discourse-modal-title">{{title}}</h3>
|
||||
|
||||
{{#if subtitle}}
|
||||
<p>{{subtitle}}</p>
|
||||
|
|
Loading…
Reference in New Issue
Block a user