Status Update
Comments
no...@google.com <no...@google.com>
se...@google.com <se...@google.com> #2
Forgot to add a sample code! Here it goes:
SelectionContainer {
LazyColumn {
items(100) {
Text("Line number $it")
}
}
}
A normal column works without any issues (expected since everything is composed unlike the LazyColumn).
Edit to give more details about my use case: I'm trying to show the lines of a text document in my app, so using a column is not an option as the files can be quite large.
se...@google.com <se...@google.com> #3
Sean, would you be able to take the first stab at it and see what's needed?
ta...@gmail.com <ta...@gmail.com> #4
This happens because the nodes containing selection are removed from the composition when they're scrolled out of view, which causes the selection container to stop tracking them. This is one of the use cases for
kl...@google.com <kl...@google.com> #5
BasicText
to pin itself when it's participating in selection.
to...@steadfastinnovation.com <to...@steadfastinnovation.com> #6
It'd be interesting to test how it can affect performance when selecting large number of lines.
kl...@google.com <kl...@google.com> #7
Confirmed that the text field is actually getting focus from the effect, so this is definitely an IME issue and not a focus one.
ha...@faire.com <ha...@faire.com> #8
Is there a workaround for this? The issue happens for components that are a part of androidx.compose.ui.window.Popup as well.
I get the following error when a BasicTextField component within a Popup requests focus:
Ignoring showSoftInput() as view=androidx.compose.ui.platform.AndroidComposeView{50b009a VFED..... .F....ID 0,0-1079,2218} is not served.
And the keyboard doesn't show.
When I try to force the keyboard to show using
val imm: InputMethodManager =
LocalContext.current.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0)
I see that the keyboard renders behind the Popup component (In my case the contents of the Popup take up a good portion of the screen).
Is there no way to control the Z axis of the contents of my Popup to show behind the system keyboard?
Or is it just not recommended to have a text input field inside a Popup at all?
kl...@google.com <kl...@google.com>
ap...@google.com <ap...@google.com> #9
Branch: androidx-main
commit 16ad8c080ac1284a39ca331e4a6169646b82e62a
Author: Zach Klippenstein <klippenstein@google.com>
Date: Mon Nov 07 16:20:09 2022
Adopt more compat tricks to show/hide IME in Compose APIs.
showSoftInput does not show input reliably when focus is requested.
This CL updates the compose.InputMethodManager implementation
to
- When calling the IMM directly to invoke show/hide commands
(API < 30), follow the best practice of posting those calls to
the main thread instead of running them immediately.
- use WindowInsetsControllerCompat for API ≥ 30
Test: Manual on Emulator 28 & 31, both with dialog and without.
Test: New tests in TextFieldFocusTest
Bug:
Bug:
Change-Id: I0143842913f91d55a4741f16173995a0177dcd64
M compose/foundation/foundation/build.gradle
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeInputField.kt
A compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/FocusTextFieldImmediatelyDemo.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextDemos.kt
A compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextFieldsInDialogDemo.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldKeyboardScrollableInteractionTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/DefaultKeyboardActionsTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/KeyboardActionsTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/KeyboardHelper.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldFocusTest.kt
M compose/ui/ui/build.gradle
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/TextInputServiceAndroidOnStateUpdateTest.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/text/input/InputMethodManager.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/text/input/RecordingInputConnection.android.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/text/input/TextInputServiceAndroid.android.kt
M compose/ui/ui/src/test/kotlin/androidx/compose/ui/input/RecordingInputConnectionUpdateTextFieldValueTest.kt
M compose/ui/ui/src/test/kotlin/androidx/compose/ui/text/input/TextInputServiceAndroidCommandDebouncingTest.kt
ma...@marcardar.com <ma...@marcardar.com> #10
Also experiencing the same issue (1.4.0-alpha04) as #8 regarding soft keyboard showing behind dialog and so keys cannot be pressed. Any workaround?
EDIT: note, I'm using com.google.android.material.dialog.MaterialAlertDialogBuilder
and setting the content view with a ComposeView
tr...@gmail.com <tr...@gmail.com> #11
Also still experiencing this. On compose 1.3.1. Dumb workaround is to use a delay(100).
ga...@gmail.com <ga...@gmail.com> #12
co...@gmail.com <co...@gmail.com> #13
edit:
delay workaround does not solve it for me
fa...@gmail.com <fa...@gmail.com> #14
ma...@gmail.com <ma...@gmail.com> #15
A more robust workaround that worked for me was waiting for window focus.
val windowInfo = LocalWindowInfo.current
LaunchedEffect(windowInfo) {
snapshotFlow { windowInfo.isWindowFocused }.collect { isWindowFocused ->
if (isWindowFocused) {
focusRequester.requestFocus()
}
}
}
pe...@gmail.com <pe...@gmail.com> #16
pe...@gmail.com <pe...@gmail.com> #17
pe...@gmail.com <pe...@gmail.com> #18
rh...@gmail.com <rh...@gmail.com> #19
Any update on this? Experiencing this in M3 and Compose 1.6.
Causes our UI tests to fail about 20% of the time since our UI tests are written with the keyboard open and thus when it's not causes scrolling and assertion issues.
z....@ocado.com <z....@ocado.com> #21
Can you link to the commit where this was fixed? I'm interested in the implementation that fixes this. Also, is the fix available in 1.7.0-beta02 release?
Description
Jetpack Compose release version: 1.0.1 Android Studio Build:Artic Fox Kotlin version: 1.5.21
I'm trying to bring the soft keyboard up when automatically when a Dialog composable is shown that contains a TextField, however it doesn't work. This same exact code sample works if the TextField is not in a Dialog