mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-22 17:39:12 +01:00
Fix editor stale callbacks and recent item deletion
This commit is contained in:
@@ -102,14 +102,17 @@ export const Input = forwardRef<EditorView | undefined, InputProps>(function Inp
|
||||
const wrapperRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// Submit nearest form on Enter key press
|
||||
const handleKeyDown = useCallback((e: KeyboardEvent) => {
|
||||
if (e.key !== 'Enter') return;
|
||||
const handleKeyDown = useCallback(
|
||||
(e: KeyboardEvent) => {
|
||||
if (e.key !== 'Enter') return;
|
||||
|
||||
const form = wrapperRef.current?.closest('form');
|
||||
if (!isValid || form == null) return;
|
||||
const form = wrapperRef.current?.closest('form');
|
||||
if (!isValid || form == null) return;
|
||||
|
||||
form?.dispatchEvent(new Event('submit', { cancelable: true, bubbles: true }));
|
||||
}, [isValid]);
|
||||
form?.dispatchEvent(new Event('submit', { cancelable: true, bubbles: true }));
|
||||
},
|
||||
[isValid],
|
||||
);
|
||||
|
||||
return (
|
||||
<VStack ref={wrapperRef} className="w-full">
|
||||
|
||||
Reference in New Issue
Block a user