From ec9532bf3c8251f2fcea91c20c1b002d74c3390c Mon Sep 17 00:00:00 2001 From: Xavier Molloy Date: Fri, 15 Sep 2023 14:54:15 +0200 Subject: [PATCH] refactor null set for delete button --- .../mobile/ui/designsystem/component/BasicTextInput.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt index 5293b1224..2bd58b408 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/BasicTextInput.kt @@ -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 = { @@ -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 {