Skip to content

Commit

Permalink
fix(FEC-8286): make unmute button focusable (#256)
Browse files Browse the repository at this point in the history
* adding tabindex=0 to the unmute indication

adding tabindex=0 to the unmute indication so it will be focusable using the keyboard.

* add unmute indication focus with tab

* moving the class to the shell

* fix flow

* fix jsdoc
  • Loading branch information
odedhutzler committed Jul 25, 2018
1 parent 66ddc4e commit 7accc69
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
24 changes: 19 additions & 5 deletions src/components/unmute-indication/unmute-indication.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {h} from 'preact';
import {connect} from 'preact-redux';
import BaseComponent from '../base';
import {default as Icon, IconType} from '../icon';
import {KeyMap} from "../../utils/key-map";

/**
* The icon only default timeout
Expand Down Expand Up @@ -91,6 +92,18 @@ class UnmuteIndication extends BaseComponent {
}, MUTED_AUTOPLAY_ICON_ONLY_DEFAULT_TIMEOUT);
}

/**
* @param {KeyboardEvent} e - the keyDown Event
* @private
* @memberof UnmuteIndication
* @returns {void}
*/
_keyDownHandler(e: KeyboardEvent): void {
if (e.keyCode === KeyMap.ENTER) {
this.player.muted = !this.player.muted;
}
}

/**
* render component
*
Expand All @@ -106,11 +119,12 @@ class UnmuteIndication extends BaseComponent {
if (this.state.iconOnly) styleClass.push(style.showIconOnly);

return (
<div
className={styleClass.join(' ')}
onMouseOver={() => this.setState({iconOnly: false})}
onMouseOut={() => this.setState({iconOnly: true})}
onClick={() => this.player.muted = !this.player.muted}>
<div tabIndex="0" aria-label="Unmute"
className={styleClass.join(' ')}
onMouseOver={() => this.setState({iconOnly: false})}
onMouseOut={() => this.setState({iconOnly: true})}
onClick={() => this.player.muted = !this.player.muted}
onKeyDown={(e) => this._keyDownHandler(e)}>
<a className={[style.btn, style.btnDarkTransparent, style.unmuteButton].join(' ')}>
<div className={style.unmuteIconContainer}>
<Icon type={IconType.VolumeBase}/>
Expand Down
3 changes: 2 additions & 1 deletion src/styles/_shell.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@
.form-group-row > a,
.button-save-cvaa,
.slider,
.unmute-button-container,
.live-tag {
&:focus {
outline: 1px solid #00cbff;
outline: 1px solid $tab-focus-color;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/styles/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
$brand-color: #01ACCD;
$tab-focus-color: #00cbff;
$white: #FFFFFF;
$grayscale1: #333;
$grayscale2: #424242;
Expand Down

0 comments on commit 7accc69

Please sign in to comment.