A platform for community discussion. Free, open, simple.
UX: add title and aria-label to md/rich editor toggle (#31784)
Renato Atilio159aa43cfeb8
diff --git a/app/assets/javascripts/discourse/app/components/composer/toggle-switch.gjs b/app/assets/javascripts/discourse/app/components/composer/toggle-switch.gjsindex bc60150123a..323f413bfa8 100644--- a/app/assets/javascripts/discourse/app/components/composer/toggle-switch.gjs+++ b/app/assets/javascripts/discourse/app/components/composer/toggle-switch.gjs@@ -3,6 +3,7 @@ import { on } from "@ember/modifier";import { action } from "@ember/object";import concatClass from "discourse/helpers/concat-class";import icon from "discourse/helpers/d-icon";+import { i18n } from "discourse-i18n";export default class ComposerToggleSwitch extends Component {@action@@ -12,6 +13,14 @@ export default class ComposerToggleSwitch extends Component {}}+ get label() {+ if (this.args.state) {+ return i18n("composer.switch_to_markdown");+ } else {+ return i18n("composer.switch_to_rich_text");+ }+ }+<template>{{! template-lint-disable no-redundant-role }}<button@@ -22,6 +31,8 @@ export default class ComposerToggleSwitch extends Component {type="button"role="switch"aria-checked={{if @state "true" "false"}}+ aria-label={{this.label}}+ title={{this.label}}{{! template-lint-disable no-pointer-down-event-binding }}{{on "mousedown" this.mouseDown}}...attributesdiff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex bd88bb5533a..45b038dbe31 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -2753,6 +2753,8 @@ en:show_preview: "show preview"hide_preview: "hide preview"+ switch_to_markdown: "Switch to standard Markdown editor"+ switch_to_rich_text: "Switch to new rich text editor"quote_post_title: "Quote whole post"bold_label: "B"bold_title: "Strong"