diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditScreen.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditScreen.kt index b14978f..f3c36bb 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/edit/EventEditScreen.kt @@ -89,6 +89,8 @@ import androidx.compose.ui.graphics.isSpecified import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString @@ -512,6 +514,10 @@ private fun EventEditContent( // they're locked here; everything else (reminders, location, notes) is the // user's to edit. val locked = state.isManaged + // Read in the form's own window, not the picker's: the field holding focus + // lives here, so this is the controller that can put its keyboard away. + val focusManager = LocalFocusManager.current + val keyboardController = LocalSoftwareKeyboardController.current var picker by remember { mutableStateOf(null) } var showCalendarPicker by rememberSaveable { mutableStateOf(false) } var showReminderPicker by rememberSaveable { mutableStateOf(false) } @@ -1117,6 +1123,17 @@ private fun EventEditContent( null -> Unit } + // A full-screen picker over the form is a change of place, so the form's + // keyboard has no business following it there — least of all onto the + // calendar manager, which the picker can hand off to. The form's own field + // keeps its text; only focus and the IME go. + LaunchedEffect(showCalendarPicker) { + if (showCalendarPicker) { + focusManager.clearFocus(force = true) + keyboardController?.hide() + } + } + if (showCalendarPicker) { CalendarPicker( calendars = state.calendars,