refactor: Simplify touch-screen detection in message submission

This commit is contained in:
Danny Avila 2025-05-05 08:37:20 -04:00
parent c82c838d36
commit 8638442a4c
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956

View file

@ -127,13 +127,9 @@ const ChatForm = memo(({ index = 0 }: { index?: number }) => {
const { submitMessage, submitPrompt } = useSubmitMessage();
// Detects if the device is a touch-screen by checking if the primary input mechanism is coarse (e.g., a finger).
const isTouchScreen = useMemo(() => window.matchMedia?.('(pointer: coarse)').matches, []);
const onSubmit = methods.handleSubmit((data: { text: string }) => {
submitMessage(data);
// On touch-screen devices, blur the text area to dismiss the on-screen keyboard
if (isTouchScreen) {
if (window.matchMedia?.('(pointer: coarse)').matches) {
textAreaRef.current?.blur();
}
});