Skip to content

Commit

Permalink
Merge pull request #351 from Orange-OpenSource/350-bug-odstextfield-d…
Browse files Browse the repository at this point in the history
…emo-is-always-multiline

350 - bug - odstextfield demo is always multiline
  • Loading branch information
paulinea authored Nov 28, 2022
2 parents a524e94 + 0654fe1 commit 06137d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- \[Lib\] Fix filter chips display for custom themes ([#305](https://github.com/Orange-OpenSource/ods-android/issues/305))
- \[Lib\] Fix leading icon tab display for Innovation Cup theme ([#330](https://github.com/Orange-OpenSource/ods-android/issues/330))
- \[Lib\] Fix a bug where keyboard return key adds a new line in single line `OdsTextField` and `OdsOutlinedTextField` ([#350](https://github.com/Orange-OpenSource/ods-android/issues/350))

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ fun OdsOutlinedTextField(
) {
Column {
OutlinedTextField(
value = value,
onValueChange = onValueChange,
value = if (singleLine) value.filter { it != '\n' } else value,
onValueChange = { newValue ->
if (!singleLine || !newValue.contains('\n')) {
onValueChange(newValue)
}
},
modifier = modifier,
enabled = enabled,
readOnly = readOnly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,12 @@ fun OdsTextField(
Column(modifier = modifier) {
TextField(
modifier = Modifier.fillMaxWidth(),
value = value,
onValueChange = onValueChange,
value = if (singleLine) value.filter { it != '\n' } else value,
onValueChange = { newValue ->
if (!singleLine || !newValue.contains('\n')) {
onValueChange(newValue)
}
},
enabled = enabled,
readOnly = readOnly,
textStyle = OdsTheme.typography.subtitle1,
Expand Down

0 comments on commit 06137d8

Please sign in to comment.