Skip to content

Commit

Permalink
adding readonly talkback (microsoft#672)
Browse files Browse the repository at this point in the history
Co-authored-by: PraveenKumar <pyeruva@microsoft.com>
  • Loading branch information
praveen970 and PraveenKumar authored Jul 16, 2024
1 parent b57bdf1 commit eb8fafb
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.disabled
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.stateDescription
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
Expand Down Expand Up @@ -172,7 +174,13 @@ fun TextField(
value = value,
onValueChange = onValueChange,
modifier = Modifier
.semantics { contentDescription = textFieldContentDescription ?: "" }
.semantics {
contentDescription = textFieldContentDescription ?: ""
if(readOnly){
this.stateDescription = "Read-only."
this.disabled()
}
}
.testTag(TEXT_FIELD)
.padding(vertical = 12.dp)
.weight(1F)
Expand Down

0 comments on commit eb8fafb

Please sign in to comment.