A11Y: change composer role to dialog, improve aria-labels (#25666)

This commit is contained in:
Kris 2024-02-14 11:09:54 -05:00 committed by GitHub
parent acca39036b
commit 2323f09eb0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 41 additions and 2 deletions

View File

@ -22,8 +22,8 @@
{{#if this.composer.model.viewOpenOrFullscreen}}
<div
role="form"
aria-label={{i18n this.composer.saveLabel}}
role="dialog"
aria-label={{this.composer.ariaLabel}}
class="reply-area
{{if this.composer.canEditTags 'with-tags' 'without-tags'}}
{{if

View File

@ -483,6 +483,45 @@ export default class ComposerService extends Service {
return uploadIcon(this.currentUser.staff, this.siteSettings);
}
@discourseComputed(
"model.action",
"isWhispering",
"model.privateMessage",
"model.post.username"
)
ariaLabel(modelAction, isWhispering, privateMessage, postUsername) {
switch (modelAction) {
case "createSharedDraft":
return I18n.t("composer.create_shared_draft");
case "editSharedDraft":
return I18n.t("composer.edit_shared_draft");
case "createTopic":
return I18n.t("composer.composer_actions.create_topic.label");
case "privateMessage":
return I18n.t("user.new_private_message");
case "edit":
return I18n.t("composer.composer_actions.edit");
case "reply":
if (isWhispering) {
return `${I18n.t("composer.create_whisper")} ${this.site.get(
"whispers_allowed_groups_names"
)}`;
}
if (privateMessage) {
return I18n.t("composer.create_pm");
}
if (postUsername) {
return I18n.t("composer.composer_actions.reply_to_post.label", {
postUsername,
});
} else {
return I18n.t("composer.composer_actions.reply_to_topic.label");
}
default:
return I18n.t("keyboard_shortcuts_help.composing.title");
}
}
// Use this to open the composer when you are not sure whether it is
// already open and whether it already has a draft being worked on. Supports
// options to append text once the composer is open if required.