Skip to content

Commit b0b5930

Browse files
authored
fix(video): 🐛 added back static dimensions, video pause when modal close fix (#136)
1 parent e73d702 commit b0b5930

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/pageComponents/dashboard/modals/videoModal.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect } from "react";
1+
import { useEffect, useRef } from "react";
22
import find from "lodash/find";
33

44
// import ModalVideo from "react-modal-video";
@@ -14,6 +14,8 @@ import { type SingleListData } from "../../../types/apiTypes";
1414

1515
const VideoModal = ({ listData }: { listData: SingleListData[] }) => {
1616
const showVideoModal = useModalStore((state) => state.showVideoModal);
17+
const ref = useRef<HTMLVideoElement>(null);
18+
1719
const toggleShowVideoModal = useModalStore(
1820
(state) => state.toggleShowVideoModal,
1921
);
@@ -27,6 +29,8 @@ const VideoModal = ({ listData }: { listData: SingleListData[] }) => {
2729
useEffect(() => {
2830
if (!showVideoModal) {
2931
setSelectedVideoId(null);
32+
// if this is not there then video keeps playing even on modal close
33+
ref?.current?.pause();
3034
}
3135
}, [setSelectedVideoId, showVideoModal]);
3236

@@ -39,14 +43,17 @@ const VideoModal = ({ listData }: { listData: SingleListData[] }) => {
3943
<Modal
4044
open={showVideoModal}
4145
setOpen={() => toggleShowVideoModal()}
42-
wrapperClassName="h-auto w-auto max-h-full max-w-[80%] rounded-2xl outline-none"
46+
// wrapperClassName="h-auto w-auto max-w-[80%] rounded-2xl outline-none"
47+
wrapperClassName="h-[80%] w-[80%] rounded-2xl outline-none"
48+
// wrapperClassName="relative h-[100vh] w-[100vw] rounded-2xl outline-none"
4349
>
4450
{/* eslint-disable-next-line jsx-a11y/media-has-caption */}
4551
<video
4652
autoPlay
47-
className="rounded-2xl bg-black"
53+
className="h-full w-full rounded-2xl bg-black object-contain"
4854
controls
4955
preload="auto"
56+
ref={ref}
5057
src={selectedVideoData?.url}
5158
/>
5259
</Modal>

0 commit comments

Comments
 (0)