Skip to content

[web] next iteration of supporting delete-word-backward action on vir…#2927

Merged
Shagen Ogandzhanian (Schahen) merged 3 commits into
jb-mainfrom
sh/web_delete_word_backward
Mar 31, 2026
Merged

[web] next iteration of supporting delete-word-backward action on vir…#2927
Shagen Ogandzhanian (Schahen) merged 3 commits into
jb-mainfrom
sh/web_delete_word_backward

Conversation

@Schahen

@Schahen Shagen Ogandzhanian (Schahen) commented Mar 27, 2026

Copy link
Copy Markdown

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

  • [iOS] Fix 'Fast delete' not working correctly for text containing emojis

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 NativeInputEventsProcessor to compute a previous-word delete range from TextLayoutResult and apply it via DeleteSurroundingTextCommand.
  • Add a new web integration test suite for deleteWordBackward covering 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.

Comment on lines +136 to +142
sendPhysicalDeleteWordBackward()
textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑👧")

sendPhysicalDeleteWordBackward()
textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑")

sendPhysicalDeleteWordBackward()

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
sendPhysicalDeleteWordBackward()
textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑👧")
sendPhysicalDeleteWordBackward()
textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑")
sendPhysicalDeleteWordBackward()
sendVirtualDeleteWordBackward()
textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑👧")
sendVirtualDeleteWordBackward()
textFieldValue.awaitAndAssertTextEquals("compound emoji: 🧑🧑")
sendVirtualDeleteWordBackward()

Copilot uses AI. Check for mistakes.
Comment on lines +109 to +111
@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

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
@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.

Copilot uses AI. Check for mistakes.
@Schahen Shagen Ogandzhanian (Schahen) merged commit ae202c7 into jb-main Mar 31, 2026
14 of 18 checks passed
@Schahen Shagen Ogandzhanian (Schahen) deleted the sh/web_delete_word_backward branch March 31, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants