Skip to content

Commit

Permalink
Merge pull request #3985 from element-hq/feature/fga/close_keyboard_n…
Browse files Browse the repository at this point in the history
…avigation

fix : hide keyboard when TextComposer is removed from composition
  • Loading branch information
ganfra authored Dec 3, 2024
2 parents cab81a0 + a475cb8 commit 57748b4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only
* Please see LICENSE in the repository root for full details.
*/

package io.element.android.libraries.designsystem.utils

import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.platform.LocalSoftwareKeyboardController

@Composable
fun HideKeyboardWhenDisposed() {
val keyboardController = LocalSoftwareKeyboardController.current
DisposableEffect(Unit) {
onDispose {
keyboardController?.hide()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.designsystem.utils.HideKeyboardWhenDisposed
import io.element.android.libraries.matrix.api.core.EventId
import io.element.android.libraries.matrix.api.timeline.item.event.EventOrTransactionId
import io.element.android.libraries.matrix.api.timeline.item.event.toEventOrTransactionId
Expand Down Expand Up @@ -323,6 +324,7 @@ fun TextComposer(
}
}
}
HideKeyboardWhenDisposed()
}

@Composable
Expand Down

0 comments on commit 57748b4

Please sign in to comment.