Skip to content

Commit 8638442

Browse files
committed
refactor: Simplify touch-screen detection in message submission
1 parent c82c838 commit 8638442

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

client/src/components/Chat/Input/ChatForm.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,9 @@ const ChatForm = memo(({ index = 0 }: { index?: number }) => {
127127

128128
const { submitMessage, submitPrompt } = useSubmitMessage();
129129

130-
// Detects if the device is a touch-screen by checking if the primary input mechanism is coarse (e.g., a finger).
131-
const isTouchScreen = useMemo(() => window.matchMedia?.('(pointer: coarse)').matches, []);
132-
133130
const onSubmit = methods.handleSubmit((data: { text: string }) => {
134131
submitMessage(data);
135-
// On touch-screen devices, blur the text area to dismiss the on-screen keyboard
136-
if (isTouchScreen) {
132+
if (window.matchMedia?.('(pointer: coarse)').matches) {
137133
textAreaRef.current?.blur();
138134
}
139135
});

0 commit comments

Comments
 (0)