Skip to content

Commit

Permalink
refactor null set for delete button
Browse files Browse the repository at this point in the history
  • Loading branch information
xavimolloy committed Sep 18, 2023
1 parent d1386d2 commit ec9532b
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ internal fun BasicTextInput(
var deleteButtonIsVisible by remember { mutableStateOf(!inputText.isNullOrEmpty() && state != InputShellState.DISABLED) }
val focusManager = LocalFocusManager.current

val button: (@Composable () -> Unit)?
var deleteButton:
@Composable()
(() -> Unit)? = null
if (deleteButtonIsVisible) {
button = {
deleteButton = {
IconButton(
modifier = Modifier.testTag("INPUT_" + testTag + "_RESET_BUTTON").padding(Spacing.Spacing0),
icon = {
Expand All @@ -76,14 +78,12 @@ internal fun BasicTextInput(
enabled = state != InputShellState.DISABLED,
)
}
} else {
button = null
}
InputShell(
modifier = modifier.testTag("INPUT_$testTag"),
isRequiredField = isRequiredField,
title = title,
primaryButton = button,
primaryButton = deleteButton,
state = state,
legend = {
legendData?.let {
Expand Down

0 comments on commit ec9532b

Please sign in to comment.