stantronic
12/30/2023, 2:39 PMS.
12/30/2023, 5:09 PMstantronic
12/31/2023, 6:20 PMDavid Herman
01/02/2024, 6:11 PMBox(ref = ref { element -> element.focus() })
(which uses the relevant standard library focus
method linked to by @S. above; of course you can use any other standard library Element APIs here)
If you have a standard Compose HTML element like Div
or Span
(Box
is a Kobweb thing), that's discussed in the subsection: https://github.com/varabyte/kobweb?tab=readme-ov-file#compose-html-refs
and would look like:
Div(attrs = {
ref { element -> element.focus(); onDispose { } }
})
stantronic
01/03/2024, 12:42 AMonClick {
val field = document.getElementById("input") as HTMLElement
field.focus()
}
but the Kobweb API looks a bit nicer. Will give it a try. thanks 😄David Herman
01/03/2024, 3:54 AMDavid Herman
01/03/2024, 3:59 AMstantronic
01/03/2024, 9:55 AMDavid Herman
01/03/2024, 6:53 PM