脚手架中的按钮窃取焦点,而如果显示加载对话框,则读取 TextField 错误

问题描述 投票:0回答:0

我有一个对讲/可访问性问题,如果显示 LoadingDialog,则不会在文本字段上读出错误,而是按钮将窃取焦点并中断正在读出的文本字段错误

代码:

        setContent {

        val error = remember { mutableStateOf("") }
        val isError = remember { mutableStateOf(false) }
        val isLoading = remember { mutableStateOf(false) }
        val value = remember { mutableStateOf(TextFieldValue("")) }

        MyApplicationTheme {
            // A surface container using the 'background' color from the theme
            Scaffold(
                bottomBar = {
                    Button({
                        isLoading.value = true
//
                        GlobalScope.launch {
//                                delay(500L)
                            isError.value = !isError.value
                            error.value =
                                if (isError.value) "please complete this field" else ""

                            isLoading.value = false
                        }
                    }) {
                        Text("Button")
                    }
                }
            ) { paddingValues ->
                Column(modifier = Modifier.padding(paddingValues)) {
                    LoadingDialog(showLoadingDialog = isLoading.value)

                    OutlinedTextField(
                        value = value.value,
                        onValueChange = { updated: TextFieldValue -> value.value = updated },
                        modifier = Modifier.semantics {
                            liveRegion = LiveRegionMode.Polite
                        },
                        isError = isError.value,
                        label =  { if (isError.value) Text(error.value) else null }
                    )
                    TextFieldSample(
                        value = TextFieldValue(""),
                        onValueChange = {
                            value.value = it
                        },
                        label = "text field test three"
                    )

                }
            }
        }
    }

带有加载对话框的视频(未读取错误):

https://photos.app.goo.gl/69TUTHbntF5YhwRF9

没有加载对话框的视频(正确读出错误)

https://photos.google.com/photo/AF1QipOsNU8xWL_LwT6ENOHp_mpjyceataaJCG-X0DqS

android-jetpack-compose accessibility talkback
© www.soinside.com 2019 - 2024. All rights reserved.