From 3ff8642bbde69c319a3e8231e405d4513ee223c3 Mon Sep 17 00:00:00 2001 From: Collin Bolles Date: Mon, 16 Jun 2025 11:41:02 -0400 Subject: [PATCH 1/4] Start work on key down --- .../videorecord/VideoRecordField.component.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx b/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx index 665d577..671bf16 100644 --- a/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx +++ b/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx @@ -129,6 +129,21 @@ const VideoRecordField: React.FC = (props) => { setValidVideos(updateValidVideos); }; + // Support for using the space key to progress + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key == ' ') { + console.log('here'); + } + }; + + useEffect(() => { + // Listen for spaces + document.addEventListener('keydown', handleKeyDown); + return () => { + document.removeEventListener('keydown', handleKeyDown); + }; + }, []); + return ( }> From 6004e257c25af2e79cef8fced74ebb68dc669b63 Mon Sep 17 00:00:00 2001 From: Collin Bolles Date: Mon, 16 Jun 2025 12:55:50 -0400 Subject: [PATCH 2/4] Add ref to handle the current state --- .../tag/videorecord/VideoRecordField.component.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx b/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx index 671bf16..ffacf3e 100644 --- a/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx +++ b/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx @@ -33,6 +33,9 @@ const VideoRecordField: React.FC = (props) => { const client = useApolloClient(); const { tag } = useTag(); const { t } = useTranslation(); + const recordingRef = useRef(recording); + recordingRef.current = recording; + const resetState = () => { if (!props.uischema.options?.minimumRequired) { @@ -132,7 +135,8 @@ const VideoRecordField: React.FC = (props) => { // Support for using the space key to progress const handleKeyDown = (e: KeyboardEvent) => { if (e.key == ' ') { - console.log('here'); + // Toggle the recording state + setRecording(!recordingRef.current); } }; From c48d906de06f8ca880e8f7761cb3652cc3c1308c Mon Sep 17 00:00:00 2001 From: Collin Bolles Date: Mon, 16 Jun 2025 13:03:59 -0400 Subject: [PATCH 3/4] Add in automatic progression through recording --- .../tag/videorecord/VideoRecordField.component.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx b/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx index ffacf3e..04c278c 100644 --- a/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx +++ b/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx @@ -36,7 +36,6 @@ const VideoRecordField: React.FC = (props) => { const recordingRef = useRef(recording); recordingRef.current = recording; - const resetState = () => { if (!props.uischema.options?.minimumRequired) { console.error('Minimum number of videos required not specified'); @@ -108,6 +107,12 @@ const VideoRecordField: React.FC = (props) => { setVideoFragmentID(updatedVideoFragmentID); props.handleChange(props.path, updatedVideoFragmentID); } + + // Automatic progression + const activeIndex = stateRef.current?.activeIndex; + if (activeIndex !== undefined && activeIndex != validVideos.length - 1) { + setActiveIndex(activeIndex + 1) + } }; /** Store the blob and check if the video needs to be saved */ From dfbcca5ac7969e002e29041be96ba5ea9e0899c3 Mon Sep 17 00:00:00 2001 From: Collin Bolles Date: Mon, 16 Jun 2025 13:05:10 -0400 Subject: [PATCH 4/4] Fix formatting --- .../components/tag/videorecord/VideoRecordField.component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx b/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx index 04c278c..cb1a88b 100644 --- a/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx +++ b/packages/client/src/components/tag/videorecord/VideoRecordField.component.tsx @@ -111,7 +111,7 @@ const VideoRecordField: React.FC = (props) => { // Automatic progression const activeIndex = stateRef.current?.activeIndex; if (activeIndex !== undefined && activeIndex != validVideos.length - 1) { - setActiveIndex(activeIndex + 1) + setActiveIndex(activeIndex + 1); } };