From 3dc34482654a5268ce9ce9b30808515d37f18a43 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Mon, 7 Sep 2026 18:39:39 +0200 Subject: [PATCH] feat(components): let an inline text field mask its value KeyboardType.Password only tells the IME to drop suggestions; without a visual transformation a borderless password field renders the secret in the clear. --- .../floret/components/InlineTextField.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/src/main/kotlin/de/jeanlucmakiola/floret/components/InlineTextField.kt b/components/src/main/kotlin/de/jeanlucmakiola/floret/components/InlineTextField.kt index f36aa93..4ec755a 100644 --- a/components/src/main/kotlin/de/jeanlucmakiola/floret/components/InlineTextField.kt +++ b/components/src/main/kotlin/de/jeanlucmakiola/floret/components/InlineTextField.kt @@ -16,6 +16,7 @@ import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.text.input.VisualTransformation import androidx.compose.ui.unit.dp /** @@ -42,6 +43,14 @@ fun InlineTextField( imeAction: ImeAction = ImeAction.Default, /** Invoked when the IME action key (e.g. Done) is pressed. */ onImeAction: (() -> Unit)? = null, + /** + * How the value is rendered, as opposed to stored. + * + * Exists so a password can be masked. [KeyboardType.Password] alone does + * not mask anything — it only tells the IME to drop suggestions — so a + * borderless field without this renders the secret in the clear. + */ + visualTransformation: VisualTransformation = VisualTransformation.None, ) { val resolvedStyle = textStyle.copy( color = when { @@ -66,6 +75,7 @@ fun InlineTextField( keyboardActions = onImeAction?.let { action -> KeyboardActions(onAny = { action() }) } ?: KeyboardActions.Default, + visualTransformation = visualTransformation, cursorBrush = SolidColor(MaterialTheme.colorScheme.primary), decorationBox = { innerTextField -> Box {