Skip to content

Authenticator should allow integrating with Autofill in Compose #247

@pmellaaho

Description

@pmellaaho

Before creating a new issue, please confirm:

Which UI component?

Authenticator

Gradle script dependencies

// Put output below this line
amplify-authenticator = { module = "com.amplifyframework.ui:authenticator", version.ref = "1.4.3" }

Environment information

# Put output below this line
Gradle 8.11.1

Please include any relevant guides or documentation you're referencing

https://developer.android.com/develop/ui/compose/text/autofill https://ui.docs.amplify.aws/android/connected-components/authenticator/customization#full-ui-customization

Describe the bug

Compose 1.8 contains newly added support for semantic autofill. This is a significant improvement on how easy it is for users to fill and save credentials to a password manager. I use Authenticator in “Full UI customization” -mode so it should be a very straight forward job to integrate with autofill but for some reason I have not succeeded in this. Basically I have been able to implement a Password change screen in my app (for signed in users) that does integrate nicely with Autofill I.e. I can save credentials to password manager while changing the password but I can’t access those credential in my SignInScreen implementation. Based on these findings I think that when a screen is shown in Authenticator() context there is something that prevents Autofill to work.

Reproduction steps (if applicable)

No response

Code Snippet

// Put your code below this line.
val userName = state.form.fields[FieldKey.Username]!!
val password = state.form.fields[FieldKey.Password]!!
var currentUsrNameValue by rememberSaveable { mutableStateOf("") }
OutlinedTextField(
    value = currentUsrNameValue,
    onValueChange = { currentUsrNameValue = it },
    label = { Text("Username (Test)") },
    modifier = Modifier
        .fillMaxWidth()
        .semantics { contentType = ContentType.Username }
)

var currentPwValue by rememberSaveable { mutableStateOf("") }
OutlinedTextField(
    value = currentPwValue,
    onValueChange = { currentPwValue = it },
    label = { Text("Password (Test)") },
    visualTransformation = PasswordVisualTransformation(),
    modifier = Modifier
        .fillMaxWidth()
        .semantics { contentType = ContentType.Password }
)

AuthenticatorButton(
    onClick = {
        scope.launch {
            userName.state.content = currentUsrNameValue
            password.state.content = currentPwValue
            state.signIn()
        }
    },
    loading = !state.form.enabled,
    label = stringResource(R.string.amplify_ui_authenticator_button_signin),
)

Log output

// Put your logs below this line


Configuration File

No response

Additional information and screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    authenticatorThis issue relates to the Authenticator componentfeature-requestNew feature or requestpending-releaseThis issue has been fixed and will be included in a future release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions