don't automatically focus message input on mobile

This commit is contained in:
hippoz 2022-09-02 14:55:15 +03:00
parent ae7875955a
commit f8af8a78fc
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 // 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); onMount(focusTextarea);
unsubscribers.push(selectedChannel.subscribe(focusTextarea)); unsubscribers.push(selectedChannel.watch(focusTextarea));
// Handle the setMessageInput event // Handle the setMessageInput event
unsubscribers.push(setMessageInputEvent.watch((value) => { unsubscribers.push(setMessageInputEvent.watch((value) => {
messageInput = value; messageInput = value;
focusTextarea(); if (messageTextarea) {
messageTextarea.focus();
}
})); }));