Skip to content

Commit aec3530

Browse files
theuargbcgoinglove
andauthored
fix: blur prompt-input after submit to collapse mobile keyboard (#337)
Steps to reproduce: 1. open app at / on mobile 2. type 1 + 1 into prompt input 3. press "enter" (right-bottom button on the keyboard) Current behaivour: keyboard shown preserving 50% of the screen Desired behaivour: keyboard collapsed to utilize available screen --------- Co-authored-by: choi sung keun <86150470+cgoinglove@users.noreply.github.com>
1 parent 016c89d commit aec3530

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/components/mention-input.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use client";
2+
import { useIsMobile } from "@/hooks/use-mobile";
23
import Mention from "@tiptap/extension-mention";
34
import {
45
EditorContent,
@@ -70,6 +71,7 @@ export default function MentionInput({
7071
onBlur,
7172
fullWidthSuggestion = false,
7273
}: MentionInputProps) {
74+
const isMobile = useIsMobile();
7375
const [open, setOpen] = useState(false);
7476
const position = useRef<{
7577
top: number;
@@ -209,7 +211,13 @@ export default function MentionInput({
209211
!e.shiftKey &&
210212
!e.metaKey &&
211213
!e.nativeEvent.isComposing;
212-
if (isSubmit) onEnter?.();
214+
if (isSubmit) {
215+
e.preventDefault();
216+
onEnter?.();
217+
if (isMobile) {
218+
editor?.commands.blur();
219+
}
220+
}
213221
},
214222
[editor, onEnter, open],
215223
);

0 commit comments

Comments
 (0)