Skip to content

Commit 2771d62

Browse files
Merge pull request #75 from seb-oss/feature/update-talkback
[MCORE-185] Update talkback for the input component
2 parents df067c3 + c45fe2d commit 2771d62

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

components/src/main/kotlin/se/seb/gds/atoms/input/BasicInput.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import androidx.compose.foundation.layout.size
1515
import androidx.compose.foundation.text.input.InputTransformation
1616
import androidx.compose.foundation.text.input.TextFieldLineLimits
1717
import androidx.compose.foundation.text.input.TextFieldState
18-
import androidx.compose.foundation.text.input.delete
1918
import androidx.compose.foundation.text.input.then
2019
import androidx.compose.material3.Icon
2120
import androidx.compose.material3.Text
@@ -254,6 +253,21 @@ internal fun getAccessibilityDescription(
254253
descriptionBuilder.append(stringResource(id = R.string.text_field_is_editing))
255254
}
256255

256+
// Announce character count if the text field is valid. If not valid, the error message will
257+
// include the character limit information, so it would be redundant to announce it here as well.
258+
val isCharacterLimitValid =
259+
inputState.characterLimit != null && state.text.length <= inputState.characterLimit.maxCharacters
260+
if (textFieldIsFocused && isCharacterLimitValid) {
261+
descriptionBuilder.append(", ")
262+
descriptionBuilder.append(
263+
stringResource(
264+
id = R.string.text_field_characters_written,
265+
state.text.length,
266+
inputState.characterLimit.maxCharacters,
267+
),
268+
)
269+
}
270+
257271
return descriptionBuilder.toString().replace(" ,", ",").trim()
258272
}
259273

components/src/main/kotlin/se/seb/gds/atoms/input/GdsInputContained.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ fun InputContainedCore(
243243
LocalTextSelectionColors provides style.basicInputStyle.textSelectionColors,
244244
) {
245245
BasicTextField(
246-
modifier = Modifier
246+
modifier = modifier
247247
.bringIntoViewRequester(bringIntoViewRequester)
248248
.focusRequester(focusRequester)
249249
.clearAndSetSemantics {

components/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<resources>
33
<string name="common_action_close">Stäng</string>
44
<string name="text_field">Textfält</string>
5-
<string name="text_field_error_in_field">Det finns ett fel i Textfält.</string>
5+
<string name="text_field_error_in_field">Det finns ett fel i textfältet.</string>
66
<string name="text_field_character_limit_error">Du kan skriva högst %d tecken.</string>
77
<string name="text_field_edit">ändra</string>
88
<string name="text_field_is_editing">ändrar</string>

0 commit comments

Comments
 (0)