Skip to content

Commit

Permalink
Merge pull request #738 from rafsanjani/hide-keyboard-on-chat
Browse files Browse the repository at this point in the history
Hide keyboard when user taps outside input field on chat screen
  • Loading branch information
rafsanjani authored Feb 1, 2025
2 parents a322dc2 + 4f79f89 commit 4857db7
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -51,6 +53,7 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.input.ImeAction
Expand All @@ -73,9 +76,17 @@ fun DiaryChatScreenContent(
onQueryDiaries: (query: String) -> Unit = {},
) {
val focusRequester = remember { FocusRequester() }
val keyboardController = LocalSoftwareKeyboardController.current

Column(
modifier = modifier
.clickable(
indication = null,
onClick = {
keyboardController?.hide()
},
interactionSource = MutableInteractionSource(),
)
.fillMaxSize()
.animateContentSize()
.imePadding()
Expand Down

0 comments on commit 4857db7

Please sign in to comment.