Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamamas committed Dec 17, 2023
1 parent 9624bbd commit 665dec6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions composeApp/src/wasmJsMain/kotlin/HtmlView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ private class FocusSwitcher<T : Element>(
.onFocusChanged {
if (it.isFocused && !isRequesting) {
focusManager.clearFocus(force = true)
val component = info.container.firstElementChild
if(component != null) {
requestFocus(component)
}else {
moveForward()
}
}
}
.focusTarget()
Expand All @@ -75,13 +81,25 @@ private class FocusSwitcher<T : Element>(
.onFocusChanged {
if (it.isFocused && !isRequesting) {
focusManager.clearFocus(force = true)

val component = info.container.lastElementChild
if(component != null) {
requestFocus(component)
}else {
moveBackward()
}
}
}
.focusTarget()
)
}
}

private fun requestFocus(element: Element) : Unit = js("""
{
element.focus();
}
""")

private fun initializingElement(element: Element) : Unit = js("""
{
Expand Down

0 comments on commit 665dec6

Please sign in to comment.