ui: restore search focus when returning

Keep the query populated and put the cursor back at the end of the search field when the screen is restored.
This commit is contained in:
austinried
2026-10-19 13:06:27 +00:00
parent 4b3a7d1dfa
commit 2e54d09acb
2 changed files with 3 additions and 11 deletions
@@ -23,7 +23,6 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -56,13 +55,7 @@ fun SearchField(
textFieldValue = TextFieldValue(value, selection = TextRange(value.length))
}
}
var focusRequested by rememberSaveable { mutableStateOf(false) }
LaunchedEffect(Unit) {
if (!focusRequested) {
focusRequester.requestFocus()
focusRequested = true
}
}
LaunchedEffect(Unit) { focusRequester.requestFocus() }
Surface(
shape = RoundedCornerShape(8.dp),
color = MaterialTheme.colorScheme.surfaceContainerHigh,