Hide the keyboard when navigating from the chat room screen (#3878)

This commit is contained in:
Jorge Martin Espinosa 2024-11-15 19:40:48 +01:00 committed by GitHub
parent 6fa92ed978
commit 49620244c7

View file

@ -142,6 +142,11 @@ fun MessagesView(
// This is needed because the composer is inside an AndroidView that can't be affected by the FocusManager in Compose // This is needed because the composer is inside an AndroidView that can't be affected by the FocusManager in Compose
val localView = LocalView.current val localView = LocalView.current
fun hidingKeyboard(block: () -> Unit) {
localView.hideKeyboard()
block()
}
fun onContentClick(event: TimelineItem.Event) { fun onContentClick(event: TimelineItem.Event) {
Timber.v("onMessageClick= ${event.id}") Timber.v("onMessageClick= ${event.id}")
val hideKeyboard = onEventContentClick(event) val hideKeyboard = onEventContentClick(event)
@ -152,13 +157,14 @@ fun MessagesView(
fun onMessageLongClick(event: TimelineItem.Event) { fun onMessageLongClick(event: TimelineItem.Event) {
Timber.v("OnMessageLongClicked= ${event.id}") Timber.v("OnMessageLongClicked= ${event.id}")
localView.hideKeyboard() hidingKeyboard {
state.actionListState.eventSink( state.actionListState.eventSink(
ActionListEvents.ComputeForMessage( ActionListEvents.ComputeForMessage(
event = event, event = event,
userEventPermissions = state.userEventPermissions, userEventPermissions = state.userEventPermissions,
)
) )
) }
} }
fun onActionSelected(action: TimelineItemAction, event: TimelineItem.Event) { fun onActionSelected(action: TimelineItemAction, event: TimelineItem.Event) {
@ -189,13 +195,8 @@ fun MessagesView(
roomAvatar = state.roomAvatar.dataOrNull(), roomAvatar = state.roomAvatar.dataOrNull(),
heroes = state.heroes, heroes = state.heroes,
roomCallState = state.roomCallState, roomCallState = state.roomCallState,
onBackClick = { onBackClick = { hidingKeyboard { onBackClick() } },
// Since the textfield is now based on an Android view, this is no longer done automatically. onRoomDetailsClick = { hidingKeyboard { onRoomDetailsClick() } },
// We need to hide the keyboard when navigating out of this screen.
localView.hideKeyboard()
onBackClick()
},
onRoomDetailsClick = onRoomDetailsClick,
onJoinCallClick = onJoinCallClick, onJoinCallClick = onJoinCallClick,
) )
} }
@ -208,7 +209,7 @@ fun MessagesView(
.consumeWindowInsets(padding), .consumeWindowInsets(padding),
onContentClick = ::onContentClick, onContentClick = ::onContentClick,
onMessageLongClick = ::onMessageLongClick, onMessageLongClick = ::onMessageLongClick,
onUserDataClick = onUserDataClick, onUserDataClick = { hidingKeyboard { onUserDataClick(it) } },
onLinkClick = onLinkClick, onLinkClick = onLinkClick,
onReactionClick = ::onEmojiReactionClick, onReactionClick = ::onEmojiReactionClick,
onReactionLongClick = ::onEmojiReactionLongClick, onReactionLongClick = ::onEmojiReactionLongClick,