mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-06 22:12:12 +02:00
Merge pull request #1559 from yagitoshiro/fix/ime-enter-submit-chat
fix(web): don't submit chat on Enter during IME composition
This commit is contained in:
commit
deec7f0d01
3 changed files with 10 additions and 2 deletions
|
|
@ -696,7 +696,9 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
|
||||||
onKeyDown?.(e);
|
onKeyDown?.(e);
|
||||||
if (e.defaultPrevented) return;
|
if (e.defaultPrevented) return;
|
||||||
|
|
||||||
if (e.key === "Enter" && !e.shiftKey) {
|
// Ignore Enter while an IME composition is active (e.g. confirming a
|
||||||
|
// Japanese/Chinese/Korean conversion) so it doesn't submit the message.
|
||||||
|
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
onSubmit?.();
|
onSubmit?.();
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -713,6 +713,10 @@ const Composer: FC = () => {
|
||||||
// Arrow / Enter / Escape navigation for the active picker.
|
// Arrow / Enter / Escape navigation for the active picker.
|
||||||
const handleKeyDown = useCallback(
|
const handleKeyDown = useCallback(
|
||||||
(e: React.KeyboardEvent) => {
|
(e: React.KeyboardEvent) => {
|
||||||
|
// While an IME composition is active (e.g. confirming a Japanese/Chinese/
|
||||||
|
// Korean conversion), let the Enter/Arrow keys reach the IME instead of
|
||||||
|
// driving picker navigation/selection.
|
||||||
|
if (e.nativeEvent.isComposing) return;
|
||||||
if (showPromptPicker) {
|
if (showPromptPicker) {
|
||||||
if (e.key === "ArrowDown") {
|
if (e.key === "ArrowDown") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,9 @@ export const FreeComposer: FC = () => {
|
||||||
gate("mention documents");
|
gate("mention documents");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.key === "Enter" && !e.shiftKey) {
|
// Ignore Enter while an IME composition is active (e.g. confirming a
|
||||||
|
// Japanese/Chinese/Korean conversion) so it doesn't submit the message.
|
||||||
|
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (text.trim()) {
|
if (text.trim()) {
|
||||||
aui.composer().send();
|
aui.composer().send();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue