Skip to content

Commit

Permalink
fix(FEC-14141): Player v7 | For AAD bottom bar button, screen readers…
Browse files Browse the repository at this point in the history
… doesn't give indication if its on or off when user tab navigate to it.
  • Loading branch information
SivanA-Kaltura authored Sep 17, 2024
1 parent 22798cd commit fc1c165
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const COMPONENT_NAME = 'AdvancedAudioDescToggle';
@connect(mapStateToProps, bindActions(actions))
@withEventDispatcher(COMPONENT_NAME)
@withText({
advancedAudioText: 'settings.advancedAudioDescription'
advancedAudioText: 'settings.advanced_audio_description'
})
class AdvancedAudioDescToggle extends Component<any, any> {
/**
Expand Down
25 changes: 14 additions & 11 deletions src/components/advanced-audio-desc/advanced-audio-desc.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import style from '../../styles/style.scss';
import {h, Component, VNode} from 'preact';
import {Text, withText} from 'preact-i18n';
import {withText} from 'preact-i18n';
import {Icon, IconType} from '../icon';
import {withEventDispatcher} from '../event-dispatcher';
import {Tooltip} from '../tooltip';
Expand Down Expand Up @@ -35,14 +35,17 @@ const mapStateToProps = ({config, settings}) => ({
@connect(mapStateToProps, bindActions(actions))
@withPlayer
@withEventDispatcher(COMPONENT_NAME)
@withText({AdvancedAudioDescText: 'settings.advancedAudioDescription'})
@withText({
advancedAudioDescEnabledText: 'settings.advanced_audio_description_enabled',
advancedAudioDescDisabledText: 'settings.advanced_audio_description_disabled'
})
class AdvancedAudioDesc extends Component<any, any> implements IconComponent {
constructor(props: any) {
super();
registerToBottomBar(COMPONENT_NAME, props.player, () => this.registerComponent());
}

registerComponent(): any {
public registerComponent(): any {
return {
ariaLabel: () => this.getComponentText(),
displayName: COMPONENT_NAME,
Expand All @@ -56,11 +59,11 @@ class AdvancedAudioDesc extends Component<any, any> implements IconComponent {
};
}

getComponentText = (): any => {
return this.props.AdvancedAudioDescText;
public getComponentText = (): any => {
return this.props.advancedAudioDescEnabled ? this.props.advancedAudioDescEnabledText : this.props.advancedAudioDescDisabledText;
};

getSvgIcon = (): any => {
public getSvgIcon = (): any => {
return {
type: redux.useStore().getState().settings.advancedAudioDesc ? IconType.AdvancedAudioDescriptionActive : IconType.AdvancedAudioDescription
};
Expand All @@ -70,7 +73,7 @@ class AdvancedAudioDesc extends Component<any, any> implements IconComponent {
* should render component
* @returns {boolean} - whether to render the component
*/
_shouldRender(): boolean {
private _shouldRender(): boolean {
return this.props.showAdvancedAudioDescToggle;
}
/**
Expand All @@ -79,7 +82,7 @@ class AdvancedAudioDesc extends Component<any, any> implements IconComponent {
* @returns {void}
* @memberof AdvancedAudioDesc
*/
onClick = (): void => {
private onClick = (): void => {
const checked = !this.props.advancedAudioDescEnabled;
this.props.updateAdvancedAudioDesc(checked);
this.props.notifyClick({type: 'AdvancedAudioDescription', checked});
Expand All @@ -92,11 +95,11 @@ class AdvancedAudioDesc extends Component<any, any> implements IconComponent {
* @returns {React$Element} - component element
* @memberof AdvancedAudioDesc
*/
render({AdvancedAudioDescText, innerRef}: any): VNode<any> | undefined {
public render({innerRef}: any): VNode<any> | undefined {
return !this._shouldRender() ? undefined : (
<ButtonControl name={COMPONENT_NAME} className={[style.noIdleControl, this.props.classNames ? this.props.classNames.join(' ') : ''].join(' ')}>
<Tooltip label={AdvancedAudioDescText}>
<Button tabIndex="0" aria-label={AdvancedAudioDescText} className={`${style.controlButton}`} ref={innerRef} onClick={this.onClick}>
<Tooltip label={this.getComponentText()}>
<Button tabIndex="0" aria-label={this.getComponentText()} className={`${style.controlButton}`} ref={innerRef} onClick={this.onClick}>
<Icon type={this.props.advancedAudioDescEnabled ? IconType.AdvancedAudioDescriptionActive : IconType.AdvancedAudioDescription} />
</Button>
</Tooltip>
Expand Down
4 changes: 3 additions & 1 deletion translations/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
"qualityHdLabel": "Quality is HD",
"quality4kLabel": "Quality is 4k",
"quality8kLabel": "Quality is 8k",
"advancedAudioDescription": "Advanced Audio Description"
"advanced_audio_description": "Extended Audio Description",
"advanced_audio_description_enabled": "Disable Extended Audio Description",
"advanced_audio_description_disabled": "Enable Extended Audio Description"
},
"captions": {
"captions": "Captions",
Expand Down

0 comments on commit fc1c165

Please sign in to comment.