diff options
| author | David Göransson <david.goransson@mullvad.net> | 2025-01-07 10:53:44 +0100 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2025-01-07 10:53:44 +0100 |
| commit | 797e24c96157f47b99db06c33f790a03d042b9d8 (patch) | |
| tree | 95c8c02acf6ee27e2dc2be89e431ca55d6aa9bea /android | |
| parent | a5ce52ccdc2b6010fa27cb82c16708672f960589 (diff) | |
| parent | b3a4f463f0dc06967620a820c7fe18e5834742d9 (diff) | |
| download | mullvadvpn-797e24c96157f47b99db06c33f790a03d042b9d8.tar.xz mullvadvpn-797e24c96157f47b99db06c33f790a03d042b9d8.zip | |
Merge branch 'focus-search-input-and-show-keyboard-when-opening-search-droid-1627'
Diffstat (limited to 'android')
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreen.kt | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreen.kt index 737baa6f0c..be5aa0d306 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreen.kt @@ -24,12 +24,15 @@ import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Text import androidx.compose.material3.TextFieldDefaults 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.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalSoftwareKeyboardController @@ -255,7 +258,10 @@ fun SearchLocationScreen( onHideBottomSheet = { locationBottomSheetState = null }, ) Column(modifier = Modifier.padding(it)) { + val focusRequester = remember { FocusRequester() } + LaunchedEffect(Unit) { focusRequester.requestFocus() } SearchBar( + modifier = Modifier.focusRequester(focusRequester), searchTerm = state.searchTerm, backgroundColor = backgroundColor, onBackgroundColor = onBackgroundColor, @@ -325,9 +331,10 @@ private fun SearchBar( onSearchInputChanged: (String) -> Unit, hideKeyboard: () -> Unit, onGoBack: () -> Unit, + modifier: Modifier = Modifier, ) { SearchBarDefaults.InputField( - modifier = Modifier.height(Dimens.searchFieldHeightExpanded).fillMaxWidth(), + modifier = modifier.height(Dimens.searchFieldHeightExpanded).fillMaxWidth(), query = searchTerm, onQueryChange = onSearchInputChanged, onSearch = { hideKeyboard() }, |
