Skip to content

fix(textbox): Place caret by X on a tap above the text - #25489

Merged
ajpinedam merged 2 commits into
unoplatform:servicing/6.8from
ajpinedam:dev/anpi/fix.wasm.textbox.tap.above.text
Oct 29, 2026
Merged

ajpinedam merged 2 commits into
unoplatform:servicing/6.8from
ajpinedam:dev/anpi/fix.wasm.textbox.tap.above.text

Conversation

@ajpinedam

Copy link
Copy Markdown
Contributor

GitHub Issue: closes unoplatform/kahua-private#531

PR Type:

🐞 Bugfix

What changed? 🚀

On Skia, tapping a TextBox in its top border or padding (the few pixels above the text line) moved the caret to the start of the text, whatever the tap's X position. On a tablet, a finger tapping to the right of the content often lands there. The result looks random: the caret goes to the end on one tap and to the start on the next. This was reported on iPad (Skia WebAssembly).

Cause: UnicodeText.GetIndexAt returned index 0 for any point above the first line (p.Y < 0) when extendedSelection is true.

Fix: a point above the text now hit-tests the first line by its X position, the same way a point on that line does. This matches master, where the same logic arrived with the RichEditBox parity port (#23924), which is too large to backport. Points below the text are unchanged.

Because the fix is in the shared hit-test, it also changes these paths when the pointer is above the first line:

  • TextBox mouse click, drag-select and right-tap
  • TextBlock selection (IsTextSelectionEnabled)

Each of them now follows the pointer's X position on the first line instead of jumping to index 0. That is master's current behaviour.

Validation:

  • New runtime tests:

    • When_Touch_Tap_Above_Text_Places_Caret_By_X_{Android,iOS}
    • When_Touch_Tap_Above_Multiline_Text_Uses_First_Line
    • When_Mouse_Drag_Above_Text_Selects_By_X

    All of them fail without the fix, with the caret at 0, and pass with it (Skia desktop).

  • The full Given_TextBox / Given_TextBlock / Given_PasswordBox suites (375 tests) differ only by the new tests with and without the fix. The one other test that changed, When_Touch_LongPress_Shows_Grippers_Android, failed once in the run without the fix. It passed 6/6 on its own without the fix and doesn't go through this code, so that was a timing flake.

  • Checked on a real iPad (Skia WebAssembly SamplesApp, Safari). A tap on the top border goes to the start without the fix, and to the end with it.

To be backported to release/stable/6.7 after merge.

PR Checklist ✅

🤖 Generated with Claude Code

@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Oct 14, 2026
@ajpinedam
ajpinedam requested a review from ramezgerges October 14, 2026 17:29
@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 239536 has failed on Uno.UI - CI.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 240171 did not find any UI Test snapshots differences.

@mergify

mergify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@dr1rrb dr1rrb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

➡️ Medium — 1 medium, 1 low, none blocking.

Approving: the change brings the same above-the-text hit-test as master's UnicodeText.GetIndexAt (#23924), the !extendedSelection path (hyperlink hit-testing) is unchanged, keyboard up/down and gripper drags never reach the new branch, and the new tests fail without the fix.

Suggested pass: drop the Task.Delay(600), then fix the two comments.

@ajpinedam
ajpinedam enabled auto-merge October 24, 2026 01:14
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 241132 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 241132 has failed on Uno.UI - CI.

@ajpinedam
ajpinedam force-pushed the dev/anpi/fix.wasm.textbox.tap.above.text branch from f741339 to 16ffceb Compare October 28, 2026 23:26
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 242095 did not find any UI Test snapshots differences.

@ajpinedam
ajpinedam merged commit d771be6 into unoplatform:servicing/6.8 Oct 29, 2026
43 checks passed
@agneszitte

Copy link
Copy Markdown
Member

@Mergifyio backport release/stable/6.7

@mergify

mergify Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.7

✅ Backports have been created

Details

agneszitte added a commit that referenced this pull request Nov 3, 2026
…6.7/pr-25489

fix(textbox): Place caret by X on a tap above the text (backport #25489)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants