Skip to content

Commit 4b31b81

Browse files
fix(frontend): add focus to play button after seek ml-362 (#381)
1 parent aa6dd3c commit 4b31b81

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/frontend/src/libs/components/player-track/player-track.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type Properties = {
1818
const PlayerTrack: React.FC<Properties> = ({ audioUrl }: Properties) => {
1919
const audioReference = useRef<HTMLAudioElement>(null);
2020
const progressReference = useRef<HTMLButtonElement>(null);
21+
const playButtonReference = useRef<HTMLButtonElement>(null);
2122

2223
const [isPlaying, setIsPlaying] = useState<boolean>(false);
2324
const [currentTime, setCurrentTime] = useState<number>(START_TIME);
@@ -91,6 +92,7 @@ const PlayerTrack: React.FC<Properties> = ({ audioUrl }: Properties) => {
9192

9293
audioReference.current.currentTime = newTime;
9394
setCurrentTime(newTime);
95+
playButtonReference.current?.focus();
9496
}
9597
},
9698
[duration],
@@ -122,7 +124,11 @@ const PlayerTrack: React.FC<Properties> = ({ audioUrl }: Properties) => {
122124

123125
return (
124126
<div className={styles["root"]}>
125-
<button className={styles["button"]} onClick={handleClick}>
127+
<button
128+
className={styles["button"]}
129+
onClick={handleClick}
130+
ref={playButtonReference}
131+
>
126132
<Icon className={styles["icon"]} name={isPlaying ? "play" : "pause"} />
127133
<span className="visually-hidden">
128134
{isPlaying ? "Pause audio" : "Play audio"}

0 commit comments

Comments
 (0)