From 8469471a45230d1c54800fcd09db21acea3e787a Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Mon, 29 Sep 2025 11:38:03 -0600 Subject: [PATCH] keyboard press stuff --- .../ui/inputs/BusterInput/BusterInput.tsx | 25 +++++++++++-------- .../MentionInput/SubmitEnterExtension.ts | 4 +-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/web/src/components/ui/inputs/BusterInput/BusterInput.tsx b/apps/web/src/components/ui/inputs/BusterInput/BusterInput.tsx index 0d4351f7c..918fecd5d 100644 --- a/apps/web/src/components/ui/inputs/BusterInput/BusterInput.tsx +++ b/apps/web/src/components/ui/inputs/BusterInput/BusterInput.tsx @@ -95,26 +95,29 @@ export const BusterInput = ({ if (showSuggestionList && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) { commandListNavigatedRef.current = true; } + + // If Enter is pressed and command list was navigated, manually trigger selection + if (showSuggestionList && event.key === 'Enter' && commandListNavigatedRef.current) { + event.preventDefault(); + event.stopPropagation(); + // Find the currently selected item and trigger its click + const selectedItem = commandElement?.querySelector('[data-selected="true"]') as HTMLElement; + if (selectedItem) { + selectedItem.click(); + } + } }; const commandElement = commandRef.current; if (commandElement) { - commandElement.addEventListener('keydown', handleKeyDown); + commandElement.addEventListener('keydown', handleKeyDown, true); // Use capture phase return () => { - commandElement.removeEventListener('keydown', handleKeyDown); + commandElement.removeEventListener('keydown', handleKeyDown, true); }; } }, [showSuggestionList]); return ( - { - console.log('onValueChange', v); - }} - > + { - // If command list has been navigated with arrow keys, let the command list handle Enter + // If command list has been navigated, don't handle here - let the parent handle it if (commandListNavigatedRef?.current) { - return !!onPressEnter; // Let the command list handle this + return !!onPressEnter; } // Otherwise, let Tiptap handle the Enter key