The docs for `AmbientAutofillTree` note that Autof...
# compose
b
The docs for
AmbientAutofillTree
note that Autofill semantics will be replacing some of the existing autofill APIs at some point, but reference an internal issue and the comment itself seems to be over a year old. Is the plan still to leverage semantics for some of the autofill support? Ref: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:co[…]compose/ui/platform/Ambients.kt;l=58-65?q=AmbientAutofillTree
Mostly curious because while the current approach works, it’s a bit clunky and at the very least I’d expect something like this `Autofill` composable to become part of the public API
j
cc @Ralston Da Silva
r
Hi Bryan, thanks for asking. Yes that comment is pretty old. Our current thoughts are that the Autofill API will use modifiers. Here is an example of what the API might end up looking like:
Copy code
CustomComponent(
   text = text, 
   modifier = Modifier
       .autofillProperties {
           autofillDataType = AutofillDataType.Text
           autofillType = AutofillType.EmailAddress
       }
       .onAutofill{ text = it }
)
For components that we provide, we will provide the onAutofill modifier internally, and populate default autofill properties. The users can override the properties to change them:
Copy code
var name by remember { mutableStateOf("enter email address here") }
BasicTextField(
   text = name,
   onValueChanged = { text = it }
   modifier = Modifier.autofillProperties { 
       autofillType = listOf(AutofillType.EmailAddress)
  } 
)
The existing API is just a placeholder, but when we re-visit autofill, it might look something like this. Would love to hear your feedback!
b
Thanks @Ralston Da Silva, that’s exactly what I was hoping to see for autofill!!
I imagine that with Compose setting proper autofill types will be more important than with the View framework since the autofill services won’t have as much context to use to infer types
r
Yes that's right @Bryan Herbst, but we will still try to infer autofill types based on location on the screen (if it is close to a text label), and try to use accessibility properties if they are set.
f
Hi ! Any update on an upcoming Autofill API in Compose UI ? 🙂 thanks for your feedback and thanks @Bryan Herbst for your article on that subject
d
@Ralston Da Silva can I have a link to the tracking issue or MR for autofill?