[web] next iteration of supporting delete-word-backward action on vir…#2927
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves web text input handling so the deleteWordBackward action coming from virtual keyboards behaves more like the equivalent physical-keyboard “delete previous word” behavior.
Changes:
- Update
NativeInputEventsProcessorto compute a previous-word delete range fromTextLayoutResultand apply it viaDeleteSurroundingTextCommand. - Add a new web integration test suite for
deleteWordBackwardcovering virtual vs physical behavior and multiple scripts/emoji cases. - Improve web text-field test stability by awaiting an animation frame after focusing, and extend test input state to expose selection.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| compose/ui/ui/src/webMain/kotlin/androidx/compose/ui/platform/NativeInputEventsProcessor.kt | Implements word-backward deletion using layout word boundaries and DeleteSurroundingTextCommand. |
| compose/ui/ui/src/webTest/kotlin/androidx/compose/ui/platform/NativeInputEventsProcessorTest.kt | Removes earlier unit tests for deleteWordBackward behavior (now covered by new integration tests). |
| compose/ui/ui/src/webTest/kotlin/androidx/compose/ui/input/specs/TextFieldTestSpec.kt | Adds an awaitAnimationFrame() after focusing to reduce flakiness. |
| compose/ui/ui/src/webTest/kotlin/androidx/compose/ui/input/DeleteWordBackwardTests.kt | Adds new end-to-end tests for virtual/physical delete-word-backward behavior. |
| compose/ui/ui/src/webTest/kotlin/androidx/compose/ui/input/BasicTextFieldTests.kt | Exposes selection on test input state implementations. |
| compose/ui/ui/src/webTest/kotlin/androidx/compose/ui/OnCanvasTests.kt | Extends TestInputState with selection and adds necessary import. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sendPhysicalDeleteWordBackward() | ||
| textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑👧") | ||
|
|
||
| sendPhysicalDeleteWordBackward() | ||
| textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑") | ||
|
|
||
| sendPhysicalDeleteWordBackward() |
There was a problem hiding this comment.
deletePrevWordVirtualSplitFamilyEmoji is supposed to cover the virtual-keyboard path, but it calls sendPhysicalDeleteWordBackward() (alt+Backspace) and never exercises beforeInput("deleteWordBackward", …). This makes the test misleading and duplicates the physical test below. Update this test to use sendVirtualDeleteWordBackward() (and adjust assertions accordingly), or rename it if it’s intentionally testing the physical path.
| sendPhysicalDeleteWordBackward() | |
| textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑👧") | |
| sendPhysicalDeleteWordBackward() | |
| textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑") | |
| sendPhysicalDeleteWordBackward() | |
| sendVirtualDeleteWordBackward() | |
| textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑👧") | |
| sendVirtualDeleteWordBackward() | |
| textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑") | |
| sendVirtualDeleteWordBackward() |
| @Ignore | ||
| fun deletePrevWordVirtualCompoundEmoji() = runApplicationTest { | ||
| // TODO: this seems to be failing for test-related reasons, on a device it behaves as expected and need to be investigated to be unignored |
There was a problem hiding this comment.
This test is newly added but marked @Ignore with a TODO. To avoid permanently reducing coverage, please link this ignore to a tracked issue (or add a clear condition for re-enabling) and consider narrowing the failure if it’s test-only (e.g., additional frame waits, deterministic selection setup) so it can be unignored.
| @Ignore | |
| fun deletePrevWordVirtualCompoundEmoji() = runApplicationTest { | |
| // TODO: this seems to be failing for test-related reasons, on a device it behaves as expected and need to be investigated to be unignored | |
| @Ignore("b/000000000: deletePrevWordVirtualCompoundEmoji fails only in web tests; re-enable once virtual deleteWordBackward handling for compound emoji is fixed") | |
| fun deletePrevWordVirtualCompoundEmoji() = runApplicationTest { | |
| // TODO(b/000000000): Fails for test-related reasons; on-device behavior is correct. Re-enable when virtual deleteWordBackward for compound emoji matches device behavior in web tests. |
ae202c7
into
jb-main
This makes behaviour of deleteWordBackward action on virtual keyboards more consistent with what we get while triggering this event from physical keyboard
Fixes CMP-9967 [Web] Mobile. iOS. 'Fast delete' doesn't work correctly if the text contains emojis
Testing
gradlew testWeb
Release Notes
Fixes - Web