diff --git a/app/src/main/java/to/bitkit/ui/components/TextInput.kt b/app/src/main/java/to/bitkit/ui/components/TextInput.kt index 7e1666695..390f2ae7a 100644 --- a/app/src/main/java/to/bitkit/ui/components/TextInput.kt +++ b/app/src/main/java/to/bitkit/ui/components/TextInput.kt @@ -9,6 +9,11 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Text import androidx.compose.material3.TextField import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.text.TextRange import androidx.compose.ui.text.TextStyle @@ -42,6 +47,18 @@ fun TextInput( visualTransformation: VisualTransformation = VisualTransformation.None, textStyle: TextStyle = AppTextStyles.BodySSB, ) { + var textFieldValue by remember { mutableStateOf(TextFieldValue(value)) } + + // Sync external changes + LaunchedEffect(value) { + if (textFieldValue.text != value) { + textFieldValue = TextFieldValue( + text = value, + selection = TextRange(value.length) + ) + } + } + TextField( placeholder = { placeholder?.let { @@ -50,8 +67,11 @@ fun TextInput( }, isError = isError, textStyle = textStyle, - value = TextFieldValue(value, TextRange(value.length)), - onValueChange = { textFieldValue -> onValueChange(textFieldValue.text) }, + value = textFieldValue, + onValueChange = { + textFieldValue = it + onValueChange(it.text) + }, maxLines = maxLines, minLines = minLines, singleLine = singleLine, diff --git a/app/src/main/java/to/bitkit/ui/settings/advanced/ElectrumConfigScreen.kt b/app/src/main/java/to/bitkit/ui/settings/advanced/ElectrumConfigScreen.kt index cd091065f..72531e42f 100644 --- a/app/src/main/java/to/bitkit/ui/settings/advanced/ElectrumConfigScreen.kt +++ b/app/src/main/java/to/bitkit/ui/settings/advanced/ElectrumConfigScreen.kt @@ -159,6 +159,7 @@ private fun Content( placeholder = "127.0.0.1", keyboardOptions = KeyboardOptions( keyboardType = KeyboardType.Uri, + autoCorrectEnabled = false, capitalization = KeyboardCapitalization.None, imeAction = ImeAction.Next, ),