Improve usability of toggled button labels (#12426)

* feat(a11y) buttons can now have toggled-aware a11y labels
This commit is contained in:
Emmanuel Pelletier
2023-03-13 09:19:28 +01:00
committed by GitHub
parent 27765b47d7
commit 45b7f53294
15 changed files with 108 additions and 148 deletions

View File

@@ -24,30 +24,13 @@ type Props = AbstractButtonProps & {
* Implementation of a button for accessing chat pane.
*/
class ChatButton extends AbstractButton<Props, *> {
accessibilityLabel = 'toolbar.accessibilityLabel.chat';
accessibilityLabel = 'toolbar.accessibilityLabel.openChat';
toggledAccessibilityLabel = 'toolbar.accessibilityLabel.closeChat';
icon = IconMessage;
label = 'toolbar.openChat';
toggledLabel = 'toolbar.closeChat';
/**
* Retrieves tooltip dynamically.
*/
get tooltip() {
if (this._isToggled()) {
return 'toolbar.closeChat';
}
return 'toolbar.openChat';
}
/**
* Required by linter due to AbstractButton overwritten prop being writable.
*
* @param {string} _value - The value.
*/
set tooltip(_value) {
// Unused.
}
tooltip = 'toolbar.openChat';
toggledTooltip = 'toolbar.closeChat';
/**
* Indicates whether this button is in toggled state or not.