mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Fix keyboard not auto-opening when editing a message (#6412)
* fix: auto-open keyboard when editing a message * fix: show keyboard on focused editor view instead of root view
This commit is contained in:
committed by
GitHub
parent
908ad8a102
commit
800a9ab972
+2
-2
@@ -706,14 +706,14 @@ class MessageComposerPresenter(
|
|||||||
val draft = createDraftFromState(markdownTextEditorState, richTextEditorState)
|
val draft = createDraftFromState(markdownTextEditorState, richTextEditorState)
|
||||||
updateDraft(draft, isVolatile = true).join()
|
updateDraft(draft, isVolatile = true).join()
|
||||||
}
|
}
|
||||||
setText(newComposerMode.content, markdownTextEditorState, richTextEditorState)
|
setText(newComposerMode.content, markdownTextEditorState, richTextEditorState, requestFocus = true)
|
||||||
}
|
}
|
||||||
is MessageComposerMode.EditCaption -> {
|
is MessageComposerMode.EditCaption -> {
|
||||||
if (currentComposerMode.isEditing.not()) {
|
if (currentComposerMode.isEditing.not()) {
|
||||||
val draft = createDraftFromState(markdownTextEditorState, richTextEditorState)
|
val draft = createDraftFromState(markdownTextEditorState, richTextEditorState)
|
||||||
updateDraft(draft, isVolatile = true).join()
|
updateDraft(draft, isVolatile = true).join()
|
||||||
}
|
}
|
||||||
setText(newComposerMode.content, markdownTextEditorState, richTextEditorState)
|
setText(newComposerMode.content, markdownTextEditorState, richTextEditorState, requestFocus = true)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// When coming from edit, just clear the composer as it'd be weird to reset a volatile draft in this scenario.
|
// When coming from edit, just clear the composer as it'd be weird to reset a volatile draft in this scenario.
|
||||||
|
|||||||
+8
-6
@@ -15,7 +15,6 @@ import androidx.compose.runtime.rememberUpdatedState
|
|||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.viewinterop.AndroidView
|
import androidx.compose.ui.viewinterop.AndroidView
|
||||||
import io.element.android.libraries.androidutils.ui.awaitWindowFocus
|
import io.element.android.libraries.androidutils.ui.awaitWindowFocus
|
||||||
import io.element.android.libraries.androidutils.ui.isKeyboardVisible
|
|
||||||
import io.element.android.libraries.androidutils.ui.showKeyboard
|
import io.element.android.libraries.androidutils.ui.showKeyboard
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,12 +41,15 @@ internal fun <T> SoftKeyboardEffect(
|
|||||||
// Await window focus in case returning from a dialog
|
// Await window focus in case returning from a dialog
|
||||||
view.awaitWindowFocus()
|
view.awaitWindowFocus()
|
||||||
|
|
||||||
if (!view.isKeyboardVisible()) {
|
// First, focus the correct editor view
|
||||||
// Show the keyboard, temporarily using the root view for focus
|
latestOnRequestFocus()
|
||||||
view.showKeyboard(andRequestFocus = true)
|
|
||||||
|
|
||||||
// Refocus to the correct view
|
// Show keyboard on the focused editor view rather than the root view,
|
||||||
latestOnRequestFocus()
|
// as some devices require showSoftInput on the actual input view.
|
||||||
|
// Using post to run after the current focus pass completes.
|
||||||
|
view.post {
|
||||||
|
val focusedView = view.findFocus() ?: view
|
||||||
|
focusedView.showKeyboard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user