mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix: folder focus survives renaming, scrolling and filters
This commit is contained in:
1 parent
d22ef554bb
commit
af821184d5
1 file changed
+11
-3
@@ -738,16 +738,23 @@ private fun FolderSheet(
|
||||
val firstApp = remember { FocusRequester() }
|
||||
val inputMode = LocalInputModeManager.current.inputMode
|
||||
val ff = LocalFrontFocus.current
|
||||
val grid = rememberLazyGridState()
|
||||
var closing by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(renaming, inputMode) {
|
||||
if (!renaming && inputMode == InputMode.Keyboard && apps.isNotEmpty()) {
|
||||
if (!renaming && !closing && inputMode == InputMode.Keyboard && apps.isNotEmpty()) {
|
||||
grid.scrollToItem(0)
|
||||
repeat(2) { androidx.compose.runtime.withFrameNanos { } }
|
||||
runCatching { firstApp.requestFocus() }
|
||||
if (!closing) runCatching { firstApp.requestFocus() }
|
||||
}
|
||||
}
|
||||
val close = {
|
||||
closing = true
|
||||
if (renaming) commit()
|
||||
onClose()
|
||||
if (inputMode == InputMode.Keyboard) runCatching { ff?.items?.get("tile:folder:${folder.id}")?.requestFocus() }
|
||||
if (inputMode == InputMode.Keyboard && ff != null) {
|
||||
runCatching { ff.items.getValue("tile:folder:${folder.id}").requestFocus() }
|
||||
.onFailure { runCatching { ff.firstTile.requestFocus() } }
|
||||
}
|
||||
}
|
||||
BackHandler { close() }
|
||||
Box(
|
||||
@@ -788,6 +795,7 @@ private fun FolderSheet(
|
||||
}
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Adaptive(92.dp),
|
||||
state = grid,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
|
||||
Reference in new issue
Block a user