Skip to content

Commit

Permalink
Fix bug no 2 - dismiss keyboard when tap outside fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcraciunoiu committed Jul 8, 2024
1 parent 21194f7 commit ebbe244
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.provider.Settings
import androidx.activity.ComponentActivity
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -31,8 +32,10 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -363,11 +366,17 @@ private fun ReportFormScreenContent(
}) { innerPadding ->
val scrollState = rememberScrollState()
val coroutineScope = rememberCoroutineScope()
val keyboardController = LocalSoftwareKeyboardController.current

Column(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding)
.pointerInput(Unit) {
detectTapGestures(onTap = {
keyboardController?.hide()
})
}
) {
MozillaTabRow(
modifier = Modifier, tabs = state.tabs.map {
Expand Down

0 comments on commit ebbe244

Please sign in to comment.