jasu
05/14/2022, 6:50 AMModifier.clearFocusOnKeyboardDismiss
custom modifier which clears the textfield focus once softkeyboard is dismissed. It works fine until I move to “note-share” composable. Once I move to note-share composable and come back to note detail this time clearFocusOnKeyboardDismiss stops working, it doesn’t clears the focus.
Refer this video.Zach Klippenstein (he/him) [MOD]
05/15/2022, 8:28 PMjasu
05/16/2022, 5:48 AMNoteTextField(
textFieldValue = viewmodel.noteTextFieldState,
onNoteChange = viewmodel::setOnNoteChange,
isFocused = viewmodel.currentlyEditing == Note,
onFocusChanged = {
if (it.isFocused) {
viewmodel.setCurrentlyEditingState(Note)
}
},
shouldPadToNavigationBars = viewmodel.noteBackgroundChangerBottomSheetVisible,
onSoftKeyboardDismissed = {
viewmodel.setCurrentlyEditingState(None)
},
modifier = Modifier
.padding(
start = horizontalStartSpacing,
end = horizontalEndSpacing,
top = 8.dp
)
.fillMaxSize()
.imePadding(),
editable = textFieldEditable,
)
jasu
05/16/2022, 2:03 PMZach Klippenstein (he/him) [MOD]
05/16/2022, 4:47 PMclearFocusOnKeyboardDismiss
mentioned anywhere. That said, a parameter named isFocused
seems suspicious, since the actual focus state of the field is determined and owned by the focus system itself, you can’t hoist that state. Can you share the implementation of NoteTextField
as well?jasu
05/17/2022, 4:50 AMjasu
05/17/2022, 4:51 AMjasu
05/27/2022, 9:58 AMZach Klippenstein (he/him) [MOD]
06/09/2022, 4:49 PM