Skip to content

fix(web): selection, keyboard and scrolling fixes from device testing - #43

Open
SectionTN wants to merge 14 commits into
docs/web-guidefrom
fix/web-device-testing
Open

SectionTN wants to merge 14 commits into
docs/web-guidefrom
fix/web-device-testing

Conversation

@SectionTN

@SectionTN SectionTN commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

fixes from trying the selection work on phones and desktop browsers:

  1. a key pressed while the mouse was still down typed at the press point, because the textarea skipped every write during a drag. only the drag's own selections wait for its end now.
  2. a selection taller than the view lost its menu or put it under the editor. the menu clamps into the view now.
  3. a tap on an empty line put the caret on an earlier line, because an empty line's element was 0 px tall. line elements keep at least one row of height now.
  4. the insertion handle fades 4 s after the last touch on it whether its menu is open or not, and the menu stays where it opened, as on Android. it used to jump up 44 px when the handle faded. a finger held on the handle keeps it, a range selection ends it, and a page scroll or the keyboard opening no longer hides it.
  5. on Chrome for Android, dragging a handle for more than half a second dropped the keyboard and hid the handles, because Chrome blurs the focused field during any held touch. a handle drag focuses the editor again on release, as a tap and a long press already did.
  6. a long press on the line numbers in Safari on iOS opened Safari's own Copy, Look Up, Translate menu over the editor's. the gutter turns off text selection and the callout too now.
  7. with scrollEnabled={false} inside a scrolling element, like a ScrollView on the web, a mouse drag held below the fold scrolled nothing and scrollToLine left the line out of view, because both wrote window.scrollTo. the editor scrolls its nearest scrolling ancestor now and falls back to the window, and the menu hides once its selection scrolls out of that element.
  8. under avoidKeyboard, a tap inside a selection whose end sat under the keyboard slid the page up 312 px on Chrome for Android, since Chrome scrolls the page to a focused field after every tap. the hidden textarea stays above the keyboard now.
  9. with 100 underlines in view, every key rebuilt the edited line's underline boxes, 3.3 ms a key at 8x CPU throttle. each underline is a span around its text now, about 0.3 ms over plain typing.

the example also gets a readOnly toggle on the web and a minified file, and the typing bench prints none for an empty list instead of throwing.

stacked on #42 (its own commits)

A key pressed while the mouse was still down typed at the press point,
because the textarea skipped every write during a drag, and the
insertion handle vanished as the phone keyboard opened. A selection
taller than the view also lost its menu or put it under the editor.
Only the drag's own selections now wait for its end, the page and
keyboard no longer hide the handle, and the menu clamps into the view.
With 100 underlines in view, every key rebuilt the edited line's underline
boxes and read a Range rect for each piece, 3.3 ms a key at 8x CPU
throttling. Each underline is now a span around its text whose background
draws the bar or the wave, so a key repaints only its own line, about 0.3 ms
over plain typing. Selection and match boxes are read per text node, so the
span's padding never grows them, and the span takes no taps.
An empty line's element held no text, so its box was 0 px tall. A click on a
blank line put the caret on an earlier line (line 0 for line 1 of a file
that opens with an import and a blank line), because the browser's hit test
snapped to the nearest text and the fallback by row never matched a box with
no height. Line elements now keep at least one row of height.
The insertion handle faded 4 s after a tap even with its Paste menu open, and
a menu placed under the caret then jumped up 44 px, so a finger on its way to
Paste landed on the text instead. The handle now stays while the menu is open
and fades 4 s after the menu closes.
…menu

When Safari's paste prompt was dismissed, the insertion handle stayed on
screen for good. Its 4 s fade comes due while the menu is open and waits
for the menu to close, but a menu item closed the menu without telling the
editor. The menu now reports every close, so the fade starts again
whatever closed it.
A long press on the gutter in Safari on iOS selected a line number and
opened Safari's own Copy, Look Up, Translate menu on top of the editor's
menu. Only the text layer turned off text selection and the touch callout.
The gutter now does too.
On Chrome for Android, dragging a selection handle for more than half a
second dropped the keyboard and hid the handles, while the selection and
its menu stayed. Chrome blurs the focused field during any held touch, and
only a tap or a long press focused the editor again on release. A handle
drag now does too.
A tap, then a long press on a word, then an arrow key 4 s later showed an
insertion handle at the new caret for another 4 s. The handle's fade skips
while a menu is open, and the word's menu kept the tap's handle alive under
the selection. A range selection now ends the insertion handle. The test
for the handle's fade after its menu closes now closes the menu with a key
instead of a blur, which hid the handles on its own.
With scrollEnabled false inside a scrolling element, as a ScrollView renders on the web,
a mouse drag held below the fold scrolled nothing and scrollToLine left the line out of
view: both wrote window.scrollTo, and the window does not scroll in that layout. The
editor now scrolls its nearest scrolling ancestor and falls back to the window, and the
drag's fold is that element's bottom edge. The edit menu also hides once its selection
scrolls out of that element, where it stayed pinned to the element's top.
After Select all with the keyboard up, a tap inside the selection slid the page up 312 px
on Chrome Android. The hidden textarea sat at the selection end under the keyboard, and
Chrome scrolls the page to a focused field after every tap. Under avoidKeyboard the editor
already keeps the caret clear of the keyboard, so the textarea now stays above it too.
The insertion handle stayed for as long as its Paste menu was open, while
Android hides it 4 s after the last touch and leaves the menu where it is.
It was kept because the menu's anchor counted the handle only while drawn,
so a menu under the caret jumped up 44 px when it faded. The anchor now keeps
room for the handles whether drawn or faded, a finger held on the handle keeps
it, and lifting the finger starts its 4 s again.
@coderabbitai

coderabbitai Bot commented Nov 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d7f84add-a4cd-4798-a948-051c37941f1c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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.

1 participant