From 96baa9a93197bcb1ce9c8afad8f69096cf93d3a8 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Thu, 14 Mar 2024 15:50:37 +0800 Subject: [PATCH] fix dialog shortcut issue possibly fixes #1919 --- src/App.tsx | 12 +++++++++--- src/hooks/useKeyboard.js | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index a47c941d3a..0daf23b845 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2148,9 +2148,15 @@ function App() { toggleKeyboardShortcuts, toggleSettings, openSendReportDialog: () => { openSendReportDialogWithState(); }, - detectBlackScenes, - detectSilentScenes, - detectSceneChanges, + detectBlackScenes: ({ keyup }) => { + if (keyup) detectBlackScenes(); + }, + detectSilentScenes: ({ keyup }) => { + if (keyup) detectSilentScenes(); + }, + detectSceneChanges: ({ keyup }) => { + if (keyup) detectSceneChanges(); + }, createSegmentsFromKeyframes, toggleWaveformMode, toggleShowThumbnails, diff --git a/src/hooks/useKeyboard.js b/src/hooks/useKeyboard.js index a2588373a4..aaf937f890 100644 --- a/src/hooks/useKeyboard.js +++ b/src/hooks/useKeyboard.js @@ -4,7 +4,9 @@ import { useEffect, useRef } from 'react'; // Also document.addEventListener needs custom handling of modifier keys or C will be triggered by CTRL+C, etc import Mousetrap from 'mousetrap'; -const keyupActions = new Set(['seekBackwards', 'seekForwards']); +// for all dialog actions (e.g. detectSceneChanges) we must use keyup, or we risk having the button press inserted into the dialog's input element right after the dialog opens +// todo use keyup for most events? +const keyupActions = new Set(['seekBackwards', 'seekForwards', 'detectBlackScenes', 'detectSilentScenes', 'detectSceneChanges']); export default ({ keyBindings, onKeyPress: onKeyPressProp }) => { const onKeyPressRef = useRef();