fix: stop tab-complete from also swapping the selected agent (#1544)
Skill/snippet/command/file-mention autocomplete branches in ChatInput called preventDefault()+return but not stopPropagation(). The Tab key bubbled to the global window keydown listener in useKeyboardShortcuts, whose cycle_agent shortcut (default 'tab') then ran setAgent(). Add e.stopPropagation() to all four autocomplete branches so the synthetic event no longer reaches the window-level handler when an autocomplete consumes the key.
This commit is contained in:
@@ -2279,6 +2279,7 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
|
|||||||
if (showCommandAutocomplete && commandRef.current) {
|
if (showCommandAutocomplete && commandRef.current) {
|
||||||
if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') {
|
if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
commandRef.current.handleKeyDown(e.key);
|
commandRef.current.handleKeyDown(e.key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2287,6 +2288,7 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
|
|||||||
if (showSkillAutocomplete && skillRef.current) {
|
if (showSkillAutocomplete && skillRef.current) {
|
||||||
if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') {
|
if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
skillRef.current.handleKeyDown(e.key);
|
skillRef.current.handleKeyDown(e.key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2295,6 +2297,7 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
|
|||||||
if (showSnippetAutocomplete && snippetRef.current) {
|
if (showSnippetAutocomplete && snippetRef.current) {
|
||||||
if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') {
|
if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
snippetRef.current.handleKeyDown(e.key);
|
snippetRef.current.handleKeyDown(e.key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2303,6 +2306,7 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
|
|||||||
if (showFileMention && mentionRef.current) {
|
if (showFileMention && mentionRef.current) {
|
||||||
if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') {
|
if (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'Escape' || e.key === 'Tab') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
mentionRef.current.handleKeyDown(e.key);
|
mentionRef.current.handleKeyDown(e.key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user