automatically focus the message input when the user selects another channel
This commit is contained in:
parent
4080e69b11
commit
e1490f1081
1 changed files with 7 additions and 1 deletions
|
@ -1,8 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { onDestroy, onMount } from "svelte";
|
||||||
import { ArrowUpIcon } from "svelte-feather-icons";
|
import { ArrowUpIcon } from "svelte-feather-icons";
|
||||||
import request from "../request";
|
import request from "../request";
|
||||||
import { apiRoute, getItem } from "../storage";
|
import { apiRoute, getItem } from "../storage";
|
||||||
import { messagesStoreProvider, overlayStore, smallViewport, typingStore, userInfoStore } from "../stores";
|
import { messagesStoreProvider, overlayStore, selectedChannel, smallViewport, typingStore, userInfoStore } from "../stores";
|
||||||
|
|
||||||
export let channel;
|
export let channel;
|
||||||
let messageInput = "";
|
let messageInput = "";
|
||||||
|
@ -90,6 +91,11 @@
|
||||||
const onInput = () => {
|
const onInput = () => {
|
||||||
typingStore.didInputKey();
|
typingStore.didInputKey();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Focus the text area when the component first loads, or when the user selects another channel
|
||||||
|
const focusTextarea = () => messageTextarea && messageTextarea.focus();
|
||||||
|
onMount(focusTextarea);
|
||||||
|
onDestroy(selectedChannel.subscribe(focusTextarea));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
Loading…
Reference in a new issue