From 71a97fcc53eb9a98b3d2b884c65ac78c47cf89d9 Mon Sep 17 00:00:00 2001 From: linaKalt <162575174+Lkaltura@users.noreply.github.com> Date: Tue, 3 Dec 2024 10:04:58 +0200 Subject: [PATCH] fix(ADA-1593): fix focus issue on play-pause button with different player sizes (#962) issue: play-pause button is undefined , so we weren't able to perform focus action on the button solution: after discussing with @SivanA-Kaltura it's better to change the way we reference play-pause button to be able to focus on the button element when it's on bigger player sizes. --------- Co-authored-by: lianbenjamin <79077248+lianbenjamin@users.noreply.github.com> --- src/components/play-pause/play-pause.tsx | 49 +++++++++++++----------- src/components/seekbar/seekbar.tsx | 2 +- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/components/play-pause/play-pause.tsx b/src/components/play-pause/play-pause.tsx index 45b9589b4..68aec6ba6 100644 --- a/src/components/play-pause/play-pause.tsx +++ b/src/components/play-pause/play-pause.tsx @@ -1,5 +1,5 @@ import style from '../../styles/style.scss'; -import {h, Component, VNode} from 'preact'; +import { h, Component, VNode, RefObject, createRef } from 'preact'; import {withText} from 'preact-i18n'; import {connect} from 'react-redux'; import {default as Icon, IconType} from '../icon'; @@ -51,7 +51,7 @@ const COMPONENT_NAME = 'PlayPause'; title: 'controls.title' }) class PlayPause extends Component { - private _playPauseButtonRef?: HTMLButtonElement; + private _playPauseButtonRef?: RefObject = createRef(); /** * component mounted @@ -65,7 +65,7 @@ class PlayPause extends Component { eventManager.listenOnce(player, player.Event.UI.USER_CLICKED_PLAY, () => { eventManager.listenOnce(player, player.Event.Core.FIRST_PLAY, () => { if (!smallSizes.includes(this.props.playerSize)) { - this._playPauseButtonRef?.focus(); + this._playPauseButtonRef?.current?.querySelector("button")?.focus(); } }); }); @@ -97,28 +97,31 @@ class PlayPause extends Component { const playbackStateText = this.props.isPlayingAdOrPlayback ? this.props.pauseText : this.props.playText; const labelText = isStartOver ? this.props.startOverText : playbackStateText; return ( + - - - +
+ + + +
- ); + + ) + ; } } diff --git a/src/components/seekbar/seekbar.tsx b/src/components/seekbar/seekbar.tsx index 4051d00e3..8d0ceea31 100644 --- a/src/components/seekbar/seekbar.tsx +++ b/src/components/seekbar/seekbar.tsx @@ -104,7 +104,7 @@ class SeekBar extends Component { * @memberof SeekBar */ componentDidMount(): void { - const {player, eventManager, playerSize} = this.props; + const {player, eventManager} = this.props; const clientRect = this._seekBarElement.getBoundingClientRect(); this.props.updateSeekbarClientRect(clientRect); eventManager.listen(player, EventType.GUI_RESIZE, () => {