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

@@ -35,29 +35,12 @@ type Props = AbstractButtonProps & {
*/
class SharedVideoButton extends AbstractButton<Props, *> {
accessibilityLabel = 'toolbar.accessibilityLabel.sharedvideo';
toggledAccessibilityLabel = 'toolbar.accessibilityLabel.stopSharedVideo';
icon = IconPlay;
label = 'toolbar.sharedvideo';
toggledLabel = 'toolbar.stopSharedVideo';
/**
* Dynamically retrieves tooltip based on sharing state.
*/
get tooltip() {
if (this._isToggled()) {
return 'toolbar.stopSharedVideo';
}
return 'toolbar.sharedvideo';
}
/**
* Required by linter due to AbstractButton overwritten prop being writable.
*
* @param {string} _value - The icon value.
*/
set tooltip(_value) {
// Unused.
}
tooltip = 'toolbar.sharedvideo';
toggledTooltip = 'toolbar.stopSharedVideo';
/**
* Handles clicking / pressing the button, and opens a new dialog.