JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.24k stars 1.11k forks source link

FocusRequester is not working on web both js(IR) and WASM the same as in JVM #4878

Open gochev opened 1 month ago

gochev commented 1 month ago

Describe the bug FocusRequester is not working on web both js(IR) and WASM . If you set FocusRequester to some input it gets the visual feedback that its focused but in fact its not, since the focus is I guess hold by the browser.

Affected platforms

Versions

To Reproduce Run an app in wasm or js(ir) that is trying to set the focus on the first text field

  1. Run this code snippet:

    Column {
        val focusRequester = remember { FocusRequester() }
    
        var value by remember { mutableStateOf("") }
    
        TextField(modifier = Modifier.focusRequester(focusRequester), value = value, onValueChange = {
            value = it
        })
    
        LaunchedEffect(Unit) {
            focusRequester.requestFocus()
        }
    }

Expected behavior The focus should be set on this textfield and you can start typing rightaway. Like if you visit google.com or any website

Additional context The visual indication is there but you cannot type. If however you hit TAB you will be able to write into the text field.

egorikftp commented 4 weeks ago

Can be related to https://github.com/JetBrains/compose-multiplatform/issues/4673