Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const VideoRecordField: React.FC<ControlProps> = (props) => {
const client = useApolloClient();
const { tag } = useTag();
const { t } = useTranslation();
const recordingRef = useRef<boolean>(recording);
recordingRef.current = recording;

const resetState = () => {
if (!props.uischema.options?.minimumRequired) {
Expand Down Expand Up @@ -105,6 +107,12 @@ const VideoRecordField: React.FC<ControlProps> = (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 */
Expand All @@ -129,6 +137,22 @@ const VideoRecordField: React.FC<ControlProps> = (props) => {
setValidVideos(updateValidVideos);
};

// Support for using the space key to progress
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key == ' ') {
// Toggle the recording state
setRecording(!recordingRef.current);
}
};

useEffect(() => {
// Listen for spaces
document.addEventListener('keydown', handleKeyDown);
return () => {
document.removeEventListener('keydown', handleKeyDown);
};
}, []);

return (
<Accordion defaultExpanded>
<AccordionSummary expandIcon={<ExpandMore />}>
Expand Down