Skip to content

Commit 3650d99

Browse files
authored
fix: enter key problem (#794)
* fixed: enter key problem * docs: update notes * fix: enter key problem
1 parent f260310 commit 3650d99

File tree

4 files changed

+10
-32
lines changed

4 files changed

+10
-32
lines changed

docs/content.en/docs/release-notes/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Information about release notes of Coco Server is provided here.
3131
- fix: fixed incorrect taskbar icon display on linux #783
3232
- fix: fix data inconsistency issue on secondary pages #784
3333
- fix: incorrect status when installing extension #789
34+
- fix: enter key problem #794
3435

3536
### ✈️ Improvements
3637

src/components/Search/AssistantManager.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,14 @@ export function useAssistantManager({
134134
return handleAskAi();
135135
}
136136

137-
if (key === "Enter" && !shiftKey && !isChatMode && isTauri) {
137+
if (key === "Enter" && !shiftKey) {
138138
e.preventDefault();
139139

140-
goAskAi ? handleAskAi() : handleSubmit();
140+
if (isTauri && !isChatMode && goAskAi) {
141+
return handleAskAi();
142+
}
143+
144+
handleSubmit();
141145
}
142146
},
143147
[

src/components/Search/InputBox.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ export default function ChatInput({
128128
}
129129
}, [inputValue, disabled, onSend]);
130130

131-
useKeyboardHandlers({
132-
isChatMode,
133-
handleSubmit,
134-
curChatEnd,
135-
});
131+
useKeyboardHandlers();
136132

137133
useKeyPress(`${modifierKey}.${returnToInput}`, handleToggleFocus);
138134

src/hooks/useKeyboardHandlers.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@ import { useCallback, useEffect } from "react";
33
import { useSearchStore } from "@/stores/searchStore";
44
import { useShortcutsStore } from "@/stores/shortcutsStore";
55

6-
interface KeyboardHandlersProps {
7-
isChatMode: boolean;
8-
handleSubmit: () => void;
9-
curChatEnd?: boolean;
10-
}
11-
12-
export function useKeyboardHandlers({
13-
isChatMode,
14-
handleSubmit,
15-
curChatEnd,
16-
}: KeyboardHandlersProps) {
6+
export function useKeyboardHandlers() {
177
const {
188
setSourceData,
199
visibleExtensionStore,
@@ -47,21 +37,8 @@ export function useKeyboardHandlers({
4737

4838
return setSourceData(void 0);
4939
}
50-
51-
// Handle Enter without meta key requirement
52-
if (e.code === "Enter" && !e.shiftKey && isChatMode) {
53-
e.preventDefault();
54-
curChatEnd && handleSubmit();
55-
}
5640
},
57-
[
58-
isChatMode,
59-
handleSubmit,
60-
setSourceData,
61-
curChatEnd,
62-
modifierKey,
63-
visibleExtensionDetail,
64-
]
41+
[setSourceData, modifierKey, visibleExtensionDetail]
6542
);
6643

6744
useEffect(() => {

0 commit comments

Comments
 (0)