diff --git a/apps/client/src/common/components/input/text-input/useReactiveTextInput.tsx b/apps/client/src/common/components/input/text-input/useReactiveTextInput.tsx index 3185e40d5d..9a6beb670f 100644 --- a/apps/client/src/common/components/input/text-input/useReactiveTextInput.tsx +++ b/apps/client/src/common/components/input/text-input/useReactiveTextInput.tsx @@ -17,6 +17,7 @@ export default function useReactiveTextInput( submitOnCtrlEnter?: boolean; onCancelUpdate?: () => void; allowSubmitSameValue?: boolean; + allowSubmitOnEnterOnly?: boolean; allowKeyboardNavigation?: boolean; }, ): UseReactiveTextInputReturn { @@ -94,7 +95,15 @@ export default function useReactiveTextInput( 'Escape', (event) => { event.preventDefault(); - handleEscape(); + if (options?.allowSubmitOnEnterOnly) { + isKeyboardSubmitting.current = true; + options?.onCancelUpdate?.(); + setTimeout(() => { + isKeyboardSubmitting.current = false; + }, 0); + } else { + handleEscape(); + } }, { preventDefault: true }, ], @@ -143,7 +152,7 @@ export default function useReactiveTextInput( hotKeyHandler(event); }; - }, [handleEscape, handleSubmit, options?.submitOnCtrlEnter, options?.submitOnEnter, text]); + }, [handleEscape, handleSubmit, options?.submitOnCtrlEnter, options?.submitOnEnter, options?.allowSubmitOnEnterOnly, text]); return { value: text, diff --git a/apps/client/src/views/cuesheet/cuesheet-table/cuesheet-table-elements/SingleLineCell.tsx b/apps/client/src/views/cuesheet/cuesheet-table/cuesheet-table-elements/SingleLineCell.tsx index 9445b80cb2..8c49318209 100644 --- a/apps/client/src/views/cuesheet/cuesheet-table/cuesheet-table-elements/SingleLineCell.tsx +++ b/apps/client/src/views/cuesheet/cuesheet-table/cuesheet-table-elements/SingleLineCell.tsx @@ -20,6 +20,7 @@ const SingleLineCell = forwardRef( allowKeyboardNavigation: true, submitOnEnter: true, // single line should submit on enter submitOnCtrlEnter: true, + allowSubmitOnEnterOnly: true, onCancelUpdate: handleCancelUpdate, });