Skip to content

Commit d1909a1

Browse files
committed
Review: Go back to the previous version and only remove fillMaxWidth from BasicTextField
1 parent 4183681 commit d1909a1

File tree

1 file changed

+16
-33
lines changed

1 file changed

+16
-33
lines changed

core/src/main/java/com/orange/ouds/core/component/OudsTextInput.kt

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,13 @@ fun OudsTextInput(
181181
val emptyText = textFieldState.text.isEmpty()
182182

183183
OudsTextInput(
184-
modifier = modifier,
185-
label = label,
186184
state = state,
187185
emptyText = emptyText,
188186
readOnly = readOnly,
189187
error = error,
190-
constrainedMaxWidth = constrainedMaxWidth,
191-
basicTextField = { modifier ->
188+
basicTextField = {
192189
BasicTextField(
193-
modifier = modifier,
190+
modifier = modifier.semantic(label),
194191
state = textFieldState,
195192
enabled = textFieldEnabled(state = state),
196193
readOnly = readOnly,
@@ -218,7 +215,8 @@ fun OudsTextInput(
218215
outlined = outlined,
219216
error = error,
220217
helperText = helperText,
221-
helperLink = helperLink
218+
helperLink = helperLink,
219+
constrainedMaxWidth = constrainedMaxWidth
222220
)
223221
}
224222
)
@@ -303,18 +301,15 @@ fun OudsTextInput(
303301
val emptyText = value.isEmpty()
304302

305303
OudsTextInput(
306-
modifier = modifier,
307-
label = label,
308304
state = state,
309305
emptyText = emptyText,
310306
readOnly = readOnly,
311307
error = error,
312-
constrainedMaxWidth = constrainedMaxWidth,
313-
basicTextField = { modifier ->
308+
basicTextField = {
314309
BasicTextField(
310+
modifier = modifier.semantic(label),
315311
value = value,
316312
onValueChange = onValueChange,
317-
modifier = modifier,
318313
enabled = textFieldEnabled(state = state),
319314
readOnly = readOnly,
320315
textStyle = textFieldTextStyle(state = state),
@@ -340,7 +335,8 @@ fun OudsTextInput(
340335
outlined = outlined,
341336
error = error,
342337
helperText = helperText,
343-
helperLink = helperLink
338+
helperLink = helperLink,
339+
constrainedMaxWidth = constrainedMaxWidth
344340
)
345341
}
346342
)
@@ -425,18 +421,15 @@ fun OudsTextInput(
425421
val emptyText = value.text.isEmpty()
426422

427423
OudsTextInput(
428-
modifier = modifier,
429-
label = label,
430424
state = state,
431425
emptyText = emptyText,
432426
readOnly = readOnly,
433427
error = error,
434-
constrainedMaxWidth = constrainedMaxWidth,
435-
basicTextField = { modifier ->
428+
basicTextField = {
436429
BasicTextField(
430+
modifier = modifier.semantic(label),
437431
value = value,
438432
onValueChange = onValueChange,
439-
modifier = modifier,
440433
enabled = textFieldEnabled(state = state),
441434
readOnly = readOnly,
442435
textStyle = textFieldTextStyle(state = state),
@@ -462,7 +455,8 @@ fun OudsTextInput(
462455
outlined = outlined,
463456
error = error,
464457
helperText = helperText,
465-
helperLink = helperLink
458+
helperLink = helperLink,
459+
constrainedMaxWidth = constrainedMaxWidth
466460
)
467461
}
468462
)
@@ -476,14 +470,11 @@ private fun Modifier.semantic(label: String?): Modifier = this.semantics {
476470

477471
@Composable
478472
internal fun OudsTextInput(
479-
label: String?,
480473
state: OudsTextInputState,
481474
emptyText: Boolean,
482475
readOnly: Boolean,
483476
error: OudsError?,
484-
constrainedMaxWidth: Boolean,
485-
modifier: Modifier,
486-
basicTextField: @Composable (modifier: Modifier) -> Unit
477+
basicTextField: @Composable () -> Unit
487478
) {
488479

489480
val isForbidden = (state == OudsTextInputState.Loading && (emptyText || error != null)) || (error != null && state in listOf(
@@ -511,16 +502,7 @@ internal fun OudsTextInput(
511502
}
512503
}
513504
) {
514-
with(OudsTheme.componentsTokens.textInput) {
515-
basicTextField(
516-
modifier
517-
.sizeIn(
518-
minWidth = sizeMinWidth.dp,
519-
maxWidth = if (constrainedMaxWidth) sizeMaxWidth.dp else Dp.Unspecified
520-
)
521-
.semantic(label)
522-
)
523-
}
505+
basicTextField()
524506
}
525507
}
526508

@@ -540,6 +522,7 @@ private fun OudsTextInputDecorator(
540522
error: OudsError?,
541523
helperText: String?,
542524
helperLink: OudsTextInputHelperLink?,
525+
constrainedMaxWidth: Boolean,
543526
) {
544527
val hasError = error != null
545528
with(OudsTheme.componentsTokens.textInput) {
@@ -570,7 +553,7 @@ private fun OudsTextInputDecorator(
570553
Column {
571554
Row(
572555
modifier = styleModifier
573-
.sizeIn(minHeight = sizeMinHeight.dp)
556+
.sizeIn(minWidth = sizeMinWidth.dp, maxWidth = if (constrainedMaxWidth) sizeMaxWidth.dp else Dp.Unspecified, minHeight = sizeMinHeight.dp)
574557
.padding(vertical = spacePaddingBlockDefault.value)
575558
.padding(
576559
start = spacePaddingInlineDefault.value,

0 commit comments

Comments
 (0)