Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

nikolai.berestevich/fix/academy-video-bug after pressing space #2183

Merged
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
12 changes: 5 additions & 7 deletions src/pages/academy/components/_video-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const VidPlayer = styled.video`
width: 100%;
max-height: 558px;
background-color: var(--color-black);
outline: none;

@media ${device.desktopS} {
max-height: 900px;
Expand All @@ -67,7 +68,7 @@ const VideoPlayer = ({ video_src, closeVideo }) => {
let vidElement

useEffect(() => {
document.addEventListener('keydown', handleEscape, false)
document.addEventListener('keydown', handleKeyboardEvent, false)

vidElement = vidRef.current
vidElement.addEventListener('enterpictureinpicture', () => {
Expand All @@ -91,14 +92,11 @@ const VideoPlayer = ({ video_src, closeVideo }) => {
setIsShow(!is_show)
}
}

return () => {
document.removeEventListener('keydown', handleEscape, false)
}
vidElement.focus()
return () => document.removeEventListener('keydown', handleKeyboardEvent, false)
}, [])

const handleEscape = (e) => {
setIsShow(!is_show)
const handleKeyboardEvent = (e) => {
if (e.key === 'Escape') {
closeVideo()
}
Expand Down