Reheating the iOS Accessibility topic. By default,...
# compose-ios
c
Reheating the iOS Accessibility topic. By default, neither
OutlinedTextField
nor
TextField
sets up additional accessibility info such as label or any additional info like placeholder value or supportingText, on iOS. Meanwhile on Android these are handled well. Is there something I miss, or is it intentionally so minimally supported on other platforms?
Source:
Copy code
var textFieldValue by remember { mutableStateOf(TextFieldValue()) }

OutlinedTextField(
    modifier = Modifier.fillMaxWidth()
        .padding(vertical = 16.dp)
        .semantics {
            contentType = ContentType.EmailAddress
        },
    value = textFieldValue,
    onValueChange = { newValue -> textFieldValue = newValue },
    label = { Text("Email") },
    supportingText = { Text("Enter a valid email address") },
    placeholder = { Text("<mailto:example@example.com|example@example.com>") }
)
What I have in mind is setting up semantics manually based on what LabelText, SupportingText, PlaceholderText is displayed, but that will override the defaults that are working correctly on Android already 😕
a
iOS and Android have different patterns of using text fields. I would recommend to check how it's implemented in native iOS apps first. Also you can use expect/actual to split the behavior between these platforms. In any case, if you think that it behaves incorrectly, feel free to file an issue in our YouTrack.
c
This is how a very simple swiftUI based TextField is read by VoiceOver.
Copy code
@State private var email: String = ""

TextField("Email", text: $email)
    .textFieldStyle(RoundedBorderTextFieldStyle())
    .keyboardType(.emailAddress)
    .autocapitalization(.none)
    .disableAutocorrection(true)