The swiss army knife of lossless video/audio editing
Release focus with Escape, and with Enter in cut time inputs
Claude929fc6187c74
diff --git a/src/renderer/src/BottomBar.tsx b/src/renderer/src/BottomBar.tsxindex 7d875d6a..a9c04229 100644--- a/src/renderer/src/BottomBar.tsx+++ b/src/renderer/src/BottomBar.tsx@@ -141,14 +141,16 @@ const CutTimeInput = memo(({ disabled, darkMode, cutTime, setCutTime, startTimeOtry {if (isEmptyEndTime(cutTimeManual)) {setTime(undefined); // clear time- return;- }+ } else if (cutTimeManual != null) {+ // Don't proceed if not a valid time value+ const timeWithOffset = parseTimecode(cutTimeManual);+ if (timeWithOffset === undefined) return;- // Don't proceed if not a valid time value- const timeWithOffset = cutTimeManual != null ? parseTimecode(cutTimeManual) : undefined;- if (timeWithOffset === undefined) return;+ setTime(timeWithOffset);+ }- setTime(timeWithOffset);+ // release focus, so that keyboard shortcuts work again https://github.com/mifi/lossless-cut/issues/2942+ e.currentTarget.querySelector('input')?.blur();} catch (err) {console.warn('Cannot submit cut time', err);}diff --git a/src/renderer/src/hooks/useKeyboard.ts b/src/renderer/src/hooks/useKeyboard.tsindex 7192f584..05e3d00a 100644--- a/src/renderer/src/hooks/useKeyboard.ts+++ b/src/renderer/src/hooks/useKeyboard.ts@@ -15,6 +15,7 @@ import isDev from '../isDev';- Go to timecode (`g` shortcut): shouldn't insert the letter `g` into input box. This also applies to all the detect* actions- Seek (autorepeat) and acceleration factor should reset after keyup- Bind keyboard action dialog should not close when its key binding (shift+slash) is triggered+- Escape in an input (and Enter in the cut time inputs) should release focus, so that keyboard shortcuts work againSee also https://github.com/mifi/lossless-cut/issues/2515*/@@ -53,6 +54,12 @@ export default ({ keyBindings, keyUpActions, getKeyboardAction, closeExportConfi}}+ // Escape releases focus from inputs, buttons etc. (outside of dialogs), so that keyboard shortcuts work again https://github.com/mifi/lossless-cut/issues/2942+ if (isEscape && !e.defaultPrevented && e.target instanceof HTMLElement && e.target !== document.body && e.target.closest('[role="dialog"], [role="alertdialog"]') == null) {+ e.target.blur();+ return;+ }+// From now on, only handle key events when focus is on document body// because we don't allow focus to anything else// except for inputs, buttons, dialogs etc, which we want allowed to handle keys normally.