compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Accessibility: `error` in `Modifier.semantics` has no effect on macOS

Open ialokim opened this issue 3 years ago • 2 comments

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.

ialokim avatar Aug 29 '22 17:08 ialokim

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")
        }
    )
}

hfhbd avatar Aug 29 '22 19:08 hfhbd

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.

ialokim avatar Aug 29 '22 20:08 ialokim