Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve participants button aria-label for screen reader users #14997

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lang/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@
"muteGUMPending": "Connecting your microphone",
"noiseSuppression": "Noise suppression",
"openChat": "Open chat",
"participants": "Open participants pane",
"participants": "Open participants pane. {{participantsCount}} participants",
"pip": "Toggle Picture-in-Picture mode",
"privateMessage": "Send private message",
"profile": "Edit your profile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { connect } from 'react-redux';
import { IReduxState } from '../../../app/types';
import { translate } from '../../../base/i18n/functions';
import { IconUsers } from '../../../base/icons/svg';
import { getParticipantCount } from '../../../base/participants/functions';
import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
import {
close as closeParticipantsPane,
Expand All @@ -29,13 +30,17 @@ interface IProps extends AbstractButtonProps {
* Whether participants feature is enabled or not.
*/
_isParticipantsPaneEnabled: boolean;

/**
* Participants count.
*/
_particioantsCount: number;
Calinteodor marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Implementation of a button for accessing participants pane.
*/
class ParticipantsPaneButton extends AbstractButton<IProps> {
accessibilityLabel = 'toolbar.accessibilityLabel.participants';
toggledAccessibilityLabel = 'toolbar.accessibilityLabel.closeParticipantsPane';
icon = IconUsers;
label = 'toolbar.participants';
Expand Down Expand Up @@ -70,6 +75,26 @@ class ParticipantsPaneButton extends AbstractButton<IProps> {
}
}


/**
* Override the _getAccessibilityLabel method to incorporate the dynamic participant count.
*
* @override
* @returns {string}
*/
_getAccessibilityLabel() {
const { t, _particioantsCount, _isOpen } = this.props;

if (_isOpen) {
return t('toolbar.accessibilityLabel.closeParticipantsPane');
}

return t('toolbar.accessibilityLabel.participants', {
participantsCount: _particioantsCount
Calinteodor marked this conversation as resolved.
Show resolved Hide resolved
});

}

/**
* Overrides AbstractButton's {@link Component#render()}.
*
Expand Down Expand Up @@ -105,7 +130,8 @@ function mapStateToProps(state: IReduxState) {

return {
_isOpen: isOpen,
_isParticipantsPaneEnabled: isParticipantsPaneEnabled(state)
_isParticipantsPaneEnabled: isParticipantsPaneEnabled(state),
_particioantsCount: getParticipantCount(state)
Calinteodor marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand Down
Loading