don't automatically focus message input on mobile

This commit is contained in:
hippoz 2022-09-02 15:08:47 +03:00
parent ae7875955a
commit 56487d1359
Signed by: hippoz
GPG key ID: 7C52899193467641

View file

@ -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();
}
}));