From 98c1d8187578bfd52961f5c134511136aa226c2f Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Thu, 6 Feb 2025 01:55:36 -0800 Subject: [PATCH] focus() fix --- .../platform/void/common/voidSettingsTypes.ts | 6 ++-- .../src/quick-edit-tsx/QuickEditChat.tsx | 3 ++ .../react/src/sidebar-tsx/SidebarChat.tsx | 29 ++++++++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/vs/platform/void/common/voidSettingsTypes.ts b/src/vs/platform/void/common/voidSettingsTypes.ts index fe79d73d..a6172f47 100644 --- a/src/vs/platform/void/common/voidSettingsTypes.ts +++ b/src/vs/platform/void/common/voidSettingsTypes.ts @@ -443,11 +443,11 @@ export const displayInfoOfFeatureName = (featureName: FeatureName) => { if (featureName === 'Autocomplete') return 'Autocomplete' else if (featureName === 'Ctrl+K') - return 'Quick Edit' + return 'Quick-Edit' else if (featureName === 'Ctrl+L') - return 'Sidebar Chat' + return 'Chat' else if (featureName === 'FastApply') - return 'Fast Apply' + return 'Apply' else throw new Error(`Feature Name ${featureName} not allowed`) } diff --git a/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx index 71609e14..7edf1e5b 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/quick-edit-tsx/QuickEditChat.tsx @@ -81,8 +81,10 @@ export const QuickEditChat = ({ const keybindingString = accessor.get('IKeybindingService').lookupKeybinding(VOID_CTRL_K_ACTION_ID)?.getLabel() + const chatAreaRef = useRef(null) return
{ textAreaRef.current?.focus() }} > { } -interface VoidInputFormProps { +interface VoidChatAreaProps { // Required children: React.ReactNode; // This will be the input component @@ -144,7 +144,7 @@ interface VoidInputFormProps { onAbort: () => void; isStreaming: boolean; isDisabled?: boolean; - formRef?: React.RefObject; + divRef: React.RefObject; // UI customization featureName: FeatureName; @@ -154,16 +154,18 @@ interface VoidInputFormProps { selections?: any[]; onSelectionsChange?: (selections: any[]) => void; + onClickAnywhere?: () => void; // Optional close button onClose?: () => void; } -export const VoidChatArea: React.FC = ({ +export const VoidChatArea: React.FC = ({ children, onSubmit, onAbort, onClose, - formRef, + onClickAnywhere, + divRef, isStreaming = false, isDisabled = false, className = '', @@ -174,8 +176,8 @@ export const VoidChatArea: React.FC = ({ onSelectionsChange, }) => { return ( -
= ({ border border-void-border-3 focus-within:border-void-border-1 hover:border-void-border-1 ${className} `} + onClick={(e) => { + onClickAnywhere?.() + }} > {/* Selections section */} {showSelections && onSelectionsChange && ( @@ -213,7 +218,8 @@ export const VoidChatArea: React.FC = ({ {/* Bottom row */}
{showModelDropdown && ( -
+
{ e.preventDefault(); e.stopPropagation() }}>
)} @@ -227,7 +233,7 @@ export const VoidChatArea: React.FC = ({ /> )}
- +
); }; @@ -660,7 +666,7 @@ export const SidebarChat = () => { const isDisabled = instructionsAreEmpty || !!isFeatureNameDisabled('Ctrl+L', settingsState) const [sidebarRef, sidebarDimensions] = useResizeObserver() - const [formRef, formDimensions] = useResizeObserver() + const [chatAreaRef, chatAreaDimensions] = useResizeObserver() const [historyRef, historyDimensions] = useResizeObserver() useScrollbarStyles(sidebarRef) @@ -725,7 +731,7 @@ export const SidebarChat = () => { py-4 ${prevMessagesHTML.length === 0 && !messageSoFar ? 'hidden' : ''} `} - style={{ maxHeight: sidebarDimensions.height - historyDimensions.height - formDimensions.height - 36 }} // the height of the previousMessages is determined by all other heights + style={{ maxHeight: sidebarDimensions.height - historyDimensions.height - chatAreaDimensions.height - 36 }} // the height of the previousMessages is determined by all other heights > {/* previous messages */} {prevMessagesHTML} @@ -760,7 +766,7 @@ export const SidebarChat = () => { }, [onSubmit]) const inputForm =
0 ? 'absolute bottom-0' : ''}`}> { showSelections={true} selections={selections || []} onSelectionsChange={chatThreadsService.setStaging.bind(chatThreadsService)} + onClickAnywhere={() => { textAreaRef.current?.focus() }} featureName="Ctrl+L" >