Hi i am having difficulty in getting compose requ...
# compose
t
Hi i am having difficulty in getting compose requestFocus to work as required on my login screen
i have two user input fields for username and password each field has its own validation rules and when a validation error exists i display an error message and want to request focus on the field in error. i have this code...
Copy code
val (usernameFocus, passwordFocus) = remember { FocusRequester.createRefs() }

LaunchedEffect(key1 = entranceState) {
    if (entranceState.isValid()) doNothing()
    else {
        when {
            entranceState.usernameError != null -> usernameFocus.requestFocus()
            entranceState.passwordError != null -> passwordFocus.requestFocus()
        }
    }
}
my issue is that when both fields are in error and the username always gets focus, which is annoying users when they are attempting to fix the password value. is there any way i can detect when the user is entering the password, e.g. the password field has focus so as not to request focus on the username field?