Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
Improve accessibility of Buttons in Webapp
Michael Telatynski335b43036dd1
diff --git a/react/features/base/toolbox/components/AbstractButton.js b/react/features/base/toolbox/components/AbstractButton.jsindex ded2269d53..c0af079d94 100644--- a/react/features/base/toolbox/components/AbstractButton.js+++ b/react/features/base/toolbox/components/AbstractButton.js@@ -230,13 +230,14 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {/*** Helper function to be implemented by subclasses, which must return a- * {@code boolean} value indicating if this button is toggled or not.+ * {@code boolean} value indicating if this button is toggled or not or+ * undefined if the button is not toggleable.** @protected- * @returns {boolean}+ * @returns {?boolean}*/_isToggled() {- return false;+ return undefined;}_onClick: (*) => void;diff --git a/react/features/base/toolbox/components/ToolboxItem.web.js b/react/features/base/toolbox/components/ToolboxItem.web.jsindex 27bfe3e3ac..b57220d6bb 100644--- a/react/features/base/toolbox/components/ToolboxItem.web.js+++ b/react/features/base/toolbox/components/ToolboxItem.web.js@@ -12,6 +12,41 @@ import type { Props } from './AbstractToolboxItem';* Web implementation of {@code AbstractToolboxItem}.*/export default class ToolboxItem extends AbstractToolboxItem<Props> {+ /**+ * Initializes a new {@code ToolboxItem} instance.+ *+ * @inheritdoc+ */+ constructor(props: Props) {+ super(props);++ this._onKeyDown = this._onKeyDown.bind(this);+ }++ _onKeyDown: (Object) => void;++ /**+ * Handles 'Enter' key on the button to trigger onClick for accessibility.+ * We should be handling Space onKeyUp but it conflicts with PTT.+ *+ * @param {Object} event - The key event.+ * @private+ * @returns {void}+ */+ _onKeyDown(event) {+ // If the event coming to the dialog has been subject to preventDefault+ // we don't handle it here.+ if (event.defaultPrevented) {+ return;+ }++ if (event.key === 'Enter') {+ event.preventDefault();+ event.stopPropagation();+ this.props.onClick();+ }+ }+/*** Handles rendering of the actual item. If the label is being shown, which* is controlled with the `showLabel` prop, the item is rendered for its@@ -27,14 +62,21 @@ export default class ToolboxItem extends AbstractToolboxItem<Props> {elementAfter,onClick,showLabel,- tooltipPosition+ tooltipPosition,+ toggled} = this.props;const className = showLabel ? 'overflow-menu-item' : 'toolbox-button';const props = {+ 'aria-pressed': toggled,+ 'aria-disabled': disabled,'aria-label': this.accessibilityLabel,className: className + (disabled ? ' disabled' : ''),- onClick: disabled ? undefined : onClick+ onClick: disabled ? undefined : onClick,+ onKeyDown: this._onKeyDown,+ tabIndex: 0,+ role: 'button'};+const elementType = showLabel ? 'li' : 'div';const useTooltip = this.tooltip && this.tooltip.length > 0;let children = (diff --git a/react/features/toolbox/components/web/ToolbarButton.js b/react/features/toolbox/components/web/ToolbarButton.jsindex e3d2998611..7ecb1fbd74 100644--- a/react/features/toolbox/components/web/ToolbarButton.js+++ b/react/features/toolbox/components/web/ToolbarButton.js@@ -40,6 +40,41 @@ class ToolbarButton extends AbstractToolbarButton<Props> {tooltipPosition: 'top'};+ /**+ * Initializes a new {@code ToolbarButton} instance.+ *+ * @inheritdoc+ */+ constructor(props: Props) {+ super(props);++ this._onKeyDown = this._onKeyDown.bind(this);+ }++ _onKeyDown: (Object) => void;++ /**+ * Handles 'Enter' key on the button to trigger onClick for accessibility.+ * We should be handling Space onKeyUp but it conflicts with PTT.+ *+ * @param {Object} event - The key event.+ * @private+ * @returns {void}+ */+ _onKeyDown(event) {+ // If the event coming to the dialog has been subject to preventDefault+ // we don't handle it here.+ if (event.defaultPrevented) {+ return;+ }++ if (event.key === 'Enter') {+ event.preventDefault();+ event.stopPropagation();+ this.props.onClick();+ }+ }+/*** Renders the button of this {@code ToolbarButton}.*@@ -52,8 +87,12 @@ class ToolbarButton extends AbstractToolbarButton<Props> {return (<divaria-label = { this.props.accessibilityLabel }+ aria-pressed = { this.props.toggled }className = 'toolbox-button'- onClick = { this.props.onClick }>+ onClick = { this.props.onClick }+ onKeyDown = { this._onKeyDown }+ role = 'button'+ tabIndex = { 0 }>{ this.props.tooltip? <Tooltipcontent = { this.props.tooltip }