Repository navigation
Conversation
…st lines On touch screens the selection handles (and Android's insertion handle) were children of the content box, inside the scroll view, the unpadded box around it and the root, all of which clip: the start's knob above the first line and the end's below the last were cut off (#4251). The handles now live in a layer over the viewport, beside the scroll view in a box that does not clip, and the root no longer clips on touch screens (the viewport inside it still clips the text). They follow the scroll offset themselves and go, taking no touches, once the middle of their line leaves the viewport. Desktops are unchanged. Fixes #4251 Agent: rust-maintainer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iOS simulator check: before / afterHead
1. Selection on the first (only) line. Before: the start knob is gone, cut at the content box's top. After: both knobs whole; the start knob hangs into the root's top padding. 2. Selection from the first line across lines (end handle dragged down to line 3). Both builds extend the selection the same way; before, the start knob is missing. 3. Dragging the start knob. Dragged 60 pt left from "unquestionably" to "b|rown": the selection grows on both builds (the hit area still takes the drag on 4. Editor with
Note: the first 20 pt swipe (the driver's Not verified: lag of the handles behind the text during momentum scrolling. The driver's steps wait for the gesture to settle before the screenshot, so every frame I could capture shows the handle on its line; this still needs a look on a device or a screen recording. 5. Root with Every handle check above (1-4) passes. Item 5 is a visible regression for an editor with a rounded root and no padding: a card-style composer with a background on its first or last block would show it. One way to keep the fix and the corners: on touch screens, give the clipping viewport box the root's corner radius (minus the border) when the root has no padding, or clip the root but leave the handle layer outside it. |
On a touch screen the root no longer clips, so the selection handles' knobs can hang past the first and last lines. Without padding, a rounded root then let the text and its backgrounds draw square past its corners and over its border. The clipping viewport now takes the root's corners inside its border and padding through an internal core flag (`parent_corners`): a view with it is mounted with its parent's inner radii, passed on through a parent that has it too, and is restyled when the parent is. No public API changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Agent: rust-maintainer
|
Follow-up to the regression found in the iOS check (item 5 of #4258 (comment)): with a rounded root, a border and no padding, the text's backgrounds drew square past the corners and over the border on touch screens. Fixed in 29c6236. On touch screens the clipping viewport now takes the root's corners, inset by the root's border and padding. The knobs still hang outside the root.
|






Fixes #4251.
On iOS and Android, the touch selection's handles were children of the content box, inside the scroll view, the unpadded box around it and the editor's root. All three clip, so the start's knob above the first line and the end's knob below the last line were cut off, whatever the root's padding.
What changed
Testing
crates/nsh-base/tests/base/rich_editor/touch.rs, using the issue's styles (rootminHeight 96, padding 12/8, plus a 2pt border, inside a view with 16pt padding):the_knobs_of_a_selection_on_the_first_and_last_lines_show_whole: each knob's box, cut by every clipping ancestor and scroll view, equals its full box. Also checks that the stems line up with the line, past the border and padding.the_knobs_of_a_selection_across_lines_show_whole: the same for a multi-line selection.the_start_s_knob_above_the_first_line_drags_its_end: a finger on the start knob (outside the content box) drags the selection to the start of the text.a_handle_goes_when_its_line_scrolls_out_of_view: after scrolling the selected line out of view, both handles hide.mainthe three visibility and scroll tests fail and the drag test passes. The headless engine does not model native hit-testing against clipped bounds, so the drag test guards against regressions; it does not reproduce the bug.cargo test -p nsh-base --test base rich_editor::passes: 311 passed, plus one Linux desktop timing test that failed under parallel load and passes 3/3 on its own.cargo clippy -p nsh-base --testsis clean.Risk
scroll_yfromon_scrollrather than scrolling natively with the content, so they may trail the text by a frame during momentum scrolling. This needs a check on a device.How to revert
Revert this PR. No data, API or migration involved.
🤖 Generated with Claude Code
🤖 Noop (rust-maintainer) · AI agent acting for @huacnlee