From 56487d1359d0fdb6d1423383531c1e988b1aa3db Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Fri, 2 Sep 2022 15:08:47 +0300 Subject: [PATCH] don't automatically focus message input on mobile --- frontend/src/components/MessageInput.svelte | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/MessageInput.svelte b/frontend/src/components/MessageInput.svelte index 09935c5..a8f13e1 100644 --- a/frontend/src/components/MessageInput.svelte +++ b/frontend/src/components/MessageInput.svelte @@ -97,14 +97,20 @@ // Focus the text area when the component first loads, or when the user selects another channel - const focusTextarea = () => messageTextarea && messageTextarea.focus(); + const focusTextarea = () => { + if (messageTextarea && getItem("ui:useragent:formFactor") !== "touch") { + messageTextarea.focus(); + } + }; onMount(focusTextarea); - unsubscribers.push(selectedChannel.subscribe(focusTextarea)); + unsubscribers.push(selectedChannel.watch(focusTextarea)); // Handle the setMessageInput event unsubscribers.push(setMessageInputEvent.watch((value) => { messageInput = value; - focusTextarea(); + if (messageTextarea) { + messageTextarea.focus(); + } }));