Skip to content

Commit

Permalink
fix(Chatbar): update autoFocus behavior for mobile devices to improve…
Browse files Browse the repository at this point in the history
… user experience
  • Loading branch information
lgmarchi committed Dec 10, 2024
1 parent dc07324 commit 9302396
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/layouts/Chatbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import { MessageEvent } from "warp-wasm"
import StoreResolver from "$lib/components/utils/StoreResolver.svelte"
import MessageText from "$lib/components/messaging/message/MessageText.svelte"
import { Keyboard } from "@capacitor/keyboard"
export let replyTo: MessageType | undefined = undefined
export let emojiClickHook: (emoji: string) => boolean
Expand Down Expand Up @@ -158,7 +159,14 @@
return result
}
let mobileAutoFocus: boolean
Keyboard.addListener("keyboardWillShow", () => {
mobileAutoFocus = true
})
onMount(async () => {
mobileAutoFocus = false
hackVariableToRefocusChatBar.set(Math.random().toString())
})
</script>
Expand All @@ -171,7 +179,7 @@
hook={`${activeChat.id}-${$hackVariableToRefocusChatBar}`}
alt
placeholder={$_("generic.placeholder")}
autoFocus={isAndroidOriOS() ? false : true}
autoFocus={isAndroidOriOS() ? mobileAutoFocus : true}
bind:value={$message}
rounded
rich={markdown}
Expand Down

0 comments on commit 9302396

Please sign in to comment.