mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix: keep ModeHeader search from stealing focus when recomposed (#1141)
Co-authored-by: ovurrsl <ovurrsl@users.noreply.github.com>
This commit is contained in:
1 parent
2d6393df24
commit
421ffc7506
2 files changed
+101
-3
No files matched your search
@@ -996,6 +996,7 @@ internal fun ModeHeader(
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
var searching by remember { mutableStateOf(query.isNotEmpty()) }
|
||||
var focusOnOpen by remember { mutableStateOf(false) }
|
||||
val open by animateFloatAsState(if (searching) 1f else 0f, Motion.sp(0.75f, 420f), label = "searchOpen")
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp), modifier = Modifier.fillMaxWidth().heightIn(min = 52.dp).padding(vertical = 4.dp)) {
|
||||
@@ -1010,11 +1011,11 @@ internal fun ModeHeader(
|
||||
Box(Modifier.width(w).graphicsLayer { alpha = (open * 1.6f).coerceAtMost(1f) }) {
|
||||
AdbTextField(
|
||||
value = query, onValueChange = onQuery, label = "", keyboardType = KeyboardType.Text, imeAction = ImeAction.Search,
|
||||
placeholder = placeholder, compact = true, focusOnShow = true,
|
||||
onFocusChange = { focused -> if (!focused && query.isEmpty()) searching = false },
|
||||
placeholder = placeholder, compact = true, focusOnShow = focusOnOpen,
|
||||
onFocusChange = { focused -> if (!focused && query.isEmpty()) { searching = false; focusOnOpen = false } },
|
||||
)
|
||||
}
|
||||
} else SearchIcon(stringResource(R.string.stores_search_open)) { searching = true }
|
||||
} else SearchIcon(stringResource(R.string.stores_search_open)) { searching = true; focusOnOpen = true }
|
||||
}
|
||||
trailing()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user