Skip to content

Commit e0f8cab

Browse files
authored
Prefix select row group errors with "Error:" announcement (#89)
* Prefix select row group errors with error announcement * Update changelog * Tidy up
1 parent fb3e782 commit e0f8cab

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Allowed headings:
1616

1717
## [Unreleased]
1818

19+
### Changed
20+
21+
* When an error is displayed on a `SelectRowGroup` component, then the error content description will have the prefix "Error:"
22+
1923
## [4.3.1] - 2022-12-28
2024

2125
### Additions

components/src/main/java/uk/gov/hmrc/components/molecule/selectrow/SelectRowGroup.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,15 @@ class SelectRowGroup @JvmOverloads constructor(
9292
fun setError(error: String) {
9393
binding.selectRowError.apply {
9494
text = error
95-
if (error.isNotEmpty()) announceForAccessibility(error)
96-
visibility = if (error.isNotEmpty()) View.VISIBLE else View.GONE
95+
if (error.isNotEmpty()) {
96+
val errorContentDescription = context.getString(R.string.accessibility_error_prefix, error)
97+
contentDescription = errorContentDescription
98+
announceForAccessibility(errorContentDescription)
99+
visibility = View.VISIBLE
100+
} else {
101+
contentDescription = error
102+
visibility = View.GONE
103+
}
97104
}
98105
}
99106

0 commit comments

Comments
 (0)