Accessibility: `error` in `Modifier.semantics` has no effect on macOS
As the title states. See the following example code:
fun main() = singleWindowApplication {
val (input, setInput) = remember { mutableStateOf("") }
TextField(
input,
setInput,
Modifier.semantics {
if (input != "") error("Test")
}
)
}
EDIT: Writing something in the text field doesn't have any effect on macOS with VoiceOver. I would expect it to read out the error as soon as it is called in the semantics block or at least when focusing the respective TextField after it was called.
Did you add the import for error? Otherwise, the std lib error function is used, which crashes your application as expected.
import androidx.compose.material.TextField
import androidx.compose.runtime.remember
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.error
import androidx.compose.ui.window.singleWindowApplication
fun main() = singleWindowApplication {
val (input, setInput) = remember { mutableStateOf("") }
TextField(
input,
setInput,
Modifier.semantics {
if (input != "") error("Test")
}
)
}
Yes, that was obviously it, my bad.
Still it doesn't have any effect on macOS with VoiceOver. I would expect it to read out the error as soon as it happens or at least when focusing the respective TextField.