iOS Safari: a swipe on a block selects text instead of the block #397

Closed
opened 2026-10-15 03:36:11 +00:00 by kayg · 13 comments
Owner

kayg on an iPhone (Safari): swiping left or right on a block selects the text, not the block. Block select by swipe (#269/#283, train c) works in the e2e runs (WebKit with touch emulation) but not on a real iPhone.

On a real iPhone, a horizontal drag in a contenteditable starts the native text selection or loupe. Our touch handling (passive listeners? touch-action? user-select? timing?) evidently loses to it.

To do:

  1. Research how others make a horizontal swipe on an editable line do something else on iOS Safari: non-passive touchstart/touchmove with preventDefault before the selection starts; touch-action: pan-y on the lines; -webkit-user-select/-webkit-touch-callout; when iOS commits to a selection; gesture-start detection thresholds; what CodeMirror 6 does on iOS (its own touch handling, EditorView.inputHandler, the contenteditable selection sync); and how ProseMirror-based and Notion-like editors do swipe or drag handles. Cite sources.
  2. Write a short plan on this issue, then fix it. Vertical scroll, tap-to-place-caret and long-press text selection must keep working.
  3. Test with WebKit touch emulation, and post a device checklist for kayg.
kayg on an iPhone (Safari): **swiping left or right on a block selects the text, not the block.** Block select by swipe (#269/#283, train c) works in the e2e runs (WebKit with touch emulation) but not on a real iPhone. On a real iPhone, a horizontal drag in a contenteditable starts the native text selection or loupe. Our touch handling (passive listeners? `touch-action`? `user-select`? timing?) evidently loses to it. To do: 1. **Research** how others make a horizontal swipe on an editable line do something else on iOS Safari: non-passive `touchstart`/`touchmove` with `preventDefault` before the selection starts; `touch-action: pan-y` on the lines; `-webkit-user-select`/`-webkit-touch-callout`; when iOS commits to a selection; gesture-start detection thresholds; what CodeMirror 6 does on iOS (its own touch handling, `EditorView.inputHandler`, the contenteditable selection sync); and how ProseMirror-based and Notion-like editors do swipe or drag handles. Cite sources. 2. Write a short plan on this issue, then fix it. Vertical scroll, tap-to-place-caret and long-press text selection must keep working. 3. Test with WebKit touch emulation, and post a device checklist for kayg.
Author
Owner

Plan (research first)

What iOS does (findings)

  1. Native text gestures only wait for touchstart. In WebKit's iOS UI process, the "touch move" deferring recognizer only holds back pan and pinch gestures. The text-selection loupe, tap-and-a-half (double-tap-drag) and long press are deferred only by touchstart (and touchend). So preventDefault() in touchmove can stop a scroll but can't veto a text selection that has already started. Source: WKContentViewInteraction.mm, deferringGestureRecognizer:shouldDeferOtherGestureRecognizer: (WebKit main), and the deferral design in r253267.
  2. Passive listeners give up the vote. WebPageProxy::handlePreventableTouchEvent sends a touch type asynchronously, and tells UIKit "not prevented", when every listener for it is passive. Our touchstart is passive. Only the first touchmove is a deferral point (m_touchMovePreventionState). After that, a prevented touchmove only makes WebKit's touch recognizer "begin", which cancels native gestures that haven't fired yet, and only while no scroll has started (scrollViewWillStartPanOrPinchGesture sets _touchEventsCanPreventNativeGestures = NO). Sources: WebPageProxy.cpp, WKTouchEventsGestureRecognizer.mm ("If default was prevented, set the state to cancel other recognizers").
  3. With the keyboard up, the loupe may start anywhere in the note. In textInteractionGesture:shouldBeginAtPoint:, a focused editable lets the loupe begin anywhere inside it. The page's only veto there is user-select: none at the point. Since iOS 13, a drag over editable text selects it (Gadget Hacks, Michael Tsai).
  4. Our code decides too late. touch.ts only calls preventDefault() once the finger has moved 32px. By then iOS has long since handed the touch to its own selection, which usually ends our touch with a touchcancel. We don't listen for that, so the block is never selected and the native selection wins.
  5. CodeMirror on iOS uses the native selection. CM6 does not draw the main selection on iOS (drawMainRange = !browser.ios), and draws iOS handles instead (codemirror/dev#1538, discuss). Its touchstart/touchmove observers mark DOM selection changes as select.pointer. So each step of the loupe reaches us as a CM selection change, and our refresh() turns it into "words selected".
  6. Why the e2e runs pass. Playwright's WebKit is desktop WebKit with synthetic touch events. It has no UIKit gesture recognizers and no loupe, and CM's browser.ios is false there. The tests check our handler's logic, never the race with iOS.
  7. Others. I found no web editor with a reliable answer here. ProseMirror users hit the same problem (forum). Discourse found that stopping touchmove breaks iOS text selection and only does it when nothing is selected (meta). Craft and Notion do their swipes natively. On iOS, touch-action: pan-y doesn't stop text interaction (Kendo notes pan-x/pan-y were unsupported on iOS for a long time).

Approach (plugin-local, packages/editor/src/blocks/)

Claiming the touch at touchstart isn't an option: it would cost scrolling, tap-to-place-caret and long-press selection. So the fix wins the race where it can and takes the block back where it can't:

  • Claim early. A touch becomes a swipe as soon as it moves ≥10px sideways (more than 2× vertical) within 300ms of touching down. From that move on, every touchmove is prevented. That is before iOS commits, so the scroll and any not-yet-fired native gesture are cancelled. The block is still only selected at 32px. Anything slower than 300ms (a hold, which is how long-press selection starts), mostly vertical (a scroll), or a second touch right after a tap (a double-tap-drag) is left to the phone.
  • touchcancel counts. If iOS takes a claimed swipe from us anyway, the cancel still selects the block.
  • Hold the block. While a swipe is claimed, and until the native selection has been quiet for 400ms (3s at most), a small state field plus a transaction filter turns any select / select.pointer change back into the selection we had. A loupe that slipped through can't turn the block into words. The next touch drops the hold at once.
  • No selectable text during the swipe. While claimed, the content gets -webkit-user-select: none, so the selection can't grow as the finger moves.
  • Chromium/Android keeps the same swipe and edge-tap behaviour: the gesture is just claimed earlier. Vertical scroll, tap-to-type and long-press selection are untouched.

Tests: extend e2e/touch-select.spec.ts with a cancelled swipe, a slow (held) drag left to the phone, a vertical drag not prevented, an early claim, and a stray selection during the hold. Then run touch-select, bar-, phone- and editor on webkit-390 and chromium-390. Emulation can't prove the iPhone result, so a device checklist follows.

## Plan (research first) ### What iOS does (findings) 1. **Native text gestures only wait for `touchstart`.** In WebKit's iOS UI process, the "touch move" deferring recognizer only holds back **pan and pinch** gestures. The text-selection loupe, tap-and-a-half (double-tap-drag) and long press are deferred only by `touchstart` (and `touchend`). So `preventDefault()` in `touchmove` can stop a scroll but can't veto a text selection that has already started. Source: `WKContentViewInteraction.mm`, `deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:` ([WebKit main](https://github.com/WebKit/WebKit/blob/main/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm)), and the deferral design in [r253267](https://trac.webkit.org/r253267). 2. **Passive listeners give up the vote.** `WebPageProxy::handlePreventableTouchEvent` sends a touch type asynchronously, and tells UIKit "not prevented", when every listener for it is passive. Our `touchstart` is passive. Only the **first** `touchmove` is a deferral point (`m_touchMovePreventionState`). After that, a prevented `touchmove` only makes WebKit's touch recognizer "begin", which cancels native gestures that haven't fired yet, and only while no scroll has started (`scrollViewWillStartPanOrPinchGesture` sets `_touchEventsCanPreventNativeGestures = NO`). Sources: [WebPageProxy.cpp](https://github.com/WebKit/WebKit/blob/main/Source/WebKit/UIProcess/WebPageProxy.cpp), [WKTouchEventsGestureRecognizer.mm](https://github.com/WebKit/WebKit/blob/main/Source/WebKit/UIProcess/ios/WKTouchEventsGestureRecognizer.mm) ("If default was prevented, set the state to cancel other recognizers"). 3. **With the keyboard up, the loupe may start anywhere in the note.** In `textInteractionGesture:shouldBeginAtPoint:`, a focused editable lets the loupe begin anywhere inside it. The page's only veto there is `user-select: none` at the point. Since iOS 13, a drag over editable text selects it ([Gadget Hacks](https://ios.gadgethacks.com/how-to/ios-13-changes-way-you-navigate-edit-text-heres-place-cursor-make-selections-perform-edits-more-0203292/), [Michael Tsai](https://mjtsai.com/blog/2020/02/10/ios-13-cursor-placement-and-text-selection/)). 4. **Our code decides too late.** `touch.ts` only calls `preventDefault()` once the finger has moved **32px**. By then iOS has long since handed the touch to its own selection, which usually ends our touch with a **`touchcancel`**. We don't listen for that, so the block is never selected and the native selection wins. 5. **CodeMirror on iOS uses the native selection.** CM6 does not draw the main selection on iOS (`drawMainRange = !browser.ios`), and draws iOS handles instead ([codemirror/dev#1538](https://github.com/codemirror/dev/issues/1538), [discuss](https://discuss.codemirror.net/t/ios-safari-missing-selection-drag-handles/9679)). Its `touchstart`/`touchmove` observers mark DOM selection changes as `select.pointer`. So each step of the loupe reaches us as a CM selection change, and our `refresh()` turns it into "words selected". 6. **Why the e2e runs pass.** Playwright's WebKit is desktop WebKit with synthetic touch events. It has no UIKit gesture recognizers and no loupe, and CM's `browser.ios` is false there. The tests check our handler's logic, never the race with iOS. 7. **Others.** I found no web editor with a reliable answer here. ProseMirror users hit the same problem ([forum](https://discuss.prosemirror.net/t/how-to-cancel-the-selection-effect-of-the-cursor-when-dragging/3288)). Discourse found that stopping `touchmove` breaks iOS text selection and only does it when nothing is selected ([meta](https://meta.discourse.org/t/cant-drag-to-extend-a-text-selection-in-the-composer-on-ios-ipados-18-x-touchmove-selection-frozen/406834)). Craft and Notion do their swipes natively. On iOS, `touch-action: pan-y` doesn't stop text interaction (Kendo notes pan-x/pan-y were unsupported on iOS for a long time). ### Approach (plugin-local, `packages/editor/src/blocks/`) Claiming the touch at `touchstart` isn't an option: it would cost scrolling, tap-to-place-caret and long-press selection. So the fix wins the race where it can and takes the block back where it can't: - **Claim early.** A touch becomes a swipe as soon as it moves **≥10px sideways (more than 2× vertical) within 300ms** of touching down. From that move on, every `touchmove` is prevented. That is before iOS commits, so the scroll and any not-yet-fired native gesture are cancelled. The block is still only selected at **32px**. Anything slower than 300ms (a hold, which is how long-press selection starts), mostly vertical (a scroll), or a second touch right after a tap (a double-tap-drag) is left to the phone. - **`touchcancel` counts.** If iOS takes a claimed swipe from us anyway, the cancel still selects the block. - **Hold the block.** While a swipe is claimed, and until the native selection has been quiet for 400ms (3s at most), a small state field plus a transaction filter turns any `select` / `select.pointer` change back into the selection we had. A loupe that slipped through can't turn the block into words. The next touch drops the hold at once. - **No selectable text during the swipe.** While claimed, the content gets `-webkit-user-select: none`, so the selection can't grow as the finger moves. - Chromium/Android keeps the same swipe and edge-tap behaviour: the gesture is just claimed earlier. Vertical scroll, tap-to-type and long-press selection are untouched. Tests: extend `e2e/touch-select.spec.ts` with a cancelled swipe, a slow (held) drag left to the phone, a vertical drag not prevented, an early claim, and a stray selection during the hold. Then run touch-select, bar-*, phone-* and editor on webkit-390 and chromium-390. Emulation can't prove the iPhone result, so a device checklist follows.
Author
Owner

Fix in PR #403 (issue/397-ios-swipe, not merged)

Changes: packages/editor/src/blocks/touch.ts now claims a swipe early: its first quick (<300ms), clearly sideways move past 10px. From then on every move is prevented, and a touchcancel still selects the block. The new packages/editor/src/blocks/swipe-hold.ts holds the block selection against selection changes from the screen. It lasts while the swipe is down, plus 400ms after the phone's selection goes quiet (3s at most). Text can't be selected while swiping. A hold, a scroll, a double-tap-drag and the left-edge back swipe stay the phone's.

Test results (emulated; this can't prove the iPhone result):

  • touch-select (11 cases, 6 new): pass on webkit-390 and chromium-390. The "phone's own selection during a swipe" case fails with the hold switched off, so it checks the fix.
  • touch-select, bar-, phone-, editor on chromium-390: 450 passed, 0 failed.
  • The same set on webkit-390: 649 passed, 0 failed. One full run was cut off by something outside it, so it was finished in parts: bar-* + editor + 189 phone-bars, then touch-select + phone-edges + phone-targets 170/170, then phone-bars 240/240.
  • packages/editor vitest: 112/112. svelte-check: 0 errors.

Device checklist for kayg (iPhone, Safari)

Emulated WebKit has no iOS gesture recognizers, so these steps are the real test. Use a note with a few paragraphs and a list. Try each one with the keyboard down (just opened, reading) and again with it up (after tapping into the text). The keyboard-up case is the one that broke.

Swipe selects the block

  1. Swipe quickly right across a paragraph, starting on the words. Expected: the block bar (Block actions) shows. No loupe, no blue word selection with handles, no Copy/Look Up menu.
  2. Same, swiping left.
  3. Same, on a list item and on a heading.
  4. Keyboard up: swipe across a different line from the one with the caret. Expected: the block bar, and the selection stays the whole line after you lift your finger, not part of it.

Things that must still be the phone's
5. Vertical scroll: drag up and down starting on text. It scrolls as before, also with a slightly diagonal drag.
6. Tap on words: the caret goes there and the keyboard comes up (text bar).
7. Long-press a word, then drag: native text selection with the loupe and handles, then the Copy/… menu. The bar shows text formatting, not block actions.
8. Double-tap a word: it selects that word (keyboard up).
9. Double-tap and drag (tap, then quickly touch again and drag): native word selection, not a block.
10. Swipe from the very left edge of the screen: Safari's back gesture, not a block.
11. Tap on the left edge/margin or a bullet: selects the block, as before. Tap a task's tick box: toggles it.

After a swipe
12. Right after a swipe-select, tap a word. Expected: the caret goes there. If the first tap is ignored, tell me (the hold is meant to let go on the next touch).
13. A slow sideways drag (taking about half a second to start moving) is not a swipe and does whatever iOS does.

If something's off, please note: iOS version, keyboard up or down, where the finger started (words / margin / bullet), and what you saw (loupe? handles? which bar?). A screen recording is ideal.

Known, out of scope here: on an iPhone, CodeMirror shows any selection with the native highlight and iOS handles (it doesn't draw its own there). So a selected block looks like selected text with handles even when the bar correctly says Block actions. A block-shaped highlight would be a separate design issue.

## Fix in PR #403 (`issue/397-ios-swipe`, not merged) **Changes:** `packages/editor/src/blocks/touch.ts` now claims a swipe early: its first quick (<300ms), clearly sideways move past 10px. From then on every move is prevented, and a `touchcancel` still selects the block. The new `packages/editor/src/blocks/swipe-hold.ts` holds the block selection against selection changes from the screen. It lasts while the swipe is down, plus 400ms after the phone's selection goes quiet (3s at most). Text can't be selected while swiping. A hold, a scroll, a double-tap-drag and the left-edge back swipe stay the phone's. **Test results (emulated; this can't prove the iPhone result):** - `touch-select` (11 cases, 6 new): pass on webkit-390 and chromium-390. The "phone's own selection during a swipe" case **fails with the hold switched off**, so it checks the fix. - touch-select, bar-*, phone-*, editor on **chromium-390: 450 passed, 0 failed**. - The same set on **webkit-390: 649 passed, 0 failed**. One full run was cut off by something outside it, so it was finished in parts: bar-* + editor + 189 phone-bars, then touch-select + phone-edges + phone-targets 170/170, then phone-bars 240/240. - `packages/editor` vitest: 112/112. `svelte-check`: 0 errors. ## Device checklist for kayg (iPhone, Safari) Emulated WebKit has no iOS gesture recognizers, so these steps are the real test. Use a note with a few paragraphs and a list. Try each one with the keyboard **down** (just opened, reading) and again with it **up** (after tapping into the text). The keyboard-up case is the one that broke. **Swipe selects the block** 1. Swipe quickly right across a paragraph, starting on the words. Expected: the block bar (Block actions) shows. No loupe, no blue word selection with handles, no Copy/Look Up menu. 2. Same, swiping left. 3. Same, on a list item and on a heading. 4. Keyboard up: swipe across a *different* line from the one with the caret. Expected: the block bar, and the selection stays the whole line after you lift your finger, not part of it. **Things that must still be the phone's** 5. Vertical scroll: drag up and down starting on text. It scrolls as before, also with a slightly diagonal drag. 6. Tap on words: the caret goes there and the keyboard comes up (text bar). 7. Long-press a word, then drag: native text selection with the loupe and handles, then the Copy/… menu. The bar shows text formatting, not block actions. 8. Double-tap a word: it selects that word (keyboard up). 9. Double-tap and drag (tap, then quickly touch again and drag): native word selection, not a block. 10. Swipe from the very left edge of the screen: Safari's back gesture, not a block. 11. Tap on the left edge/margin or a bullet: selects the block, as before. Tap a task's tick box: toggles it. **After a swipe** 12. Right after a swipe-select, tap a word. Expected: the caret goes there. If the first tap is ignored, tell me (the hold is meant to let go on the next touch). 13. A slow sideways drag (taking about half a second to start moving) is *not* a swipe and does whatever iOS does. **If something's off**, please note: iOS version, keyboard up or down, where the finger started (words / margin / bullet), and what you saw (loupe? handles? which bar?). A screen recording is ideal. **Known, out of scope here:** on an iPhone, CodeMirror shows *any* selection with the native highlight and iOS handles (it doesn't draw its own there). So a selected block looks like selected text with handles even when the bar correctly says Block actions. A block-shaped highlight would be a separate design issue.
Author
Owner

Reopened: still broken on a real iPhone (iOS 27, Safari, production, 2026-10-17). kayg swiped across a list-item block, and iOS selected the TEXT instead (native selection handles across the whole line, with no visible block selection). The fix from #403 was only verified in emulated WebKit. Next: reproduce with real UIKit gestures in the iPhone simulator (XCUITest), then fix.

**Reopened: still broken on a real iPhone (iOS 27, Safari, production, 2026-10-17).** kayg swiped across a list-item block, and iOS selected the TEXT instead (native selection handles across the whole line, with no visible block selection). The fix from #403 was only verified in emulated WebKit. Next: reproduce with real UIKit gestures in the iPhone simulator (XCUITest), then fix.
Author
Owner

Real-UIKit reproduction and fix (PR #523)

Finding. iPhone 18 Pro simulator (iOS 27), Safari tab, raw touch events from XCUITest's event classes (no wait-for-idle). Production needs a passkey, so the "before" is a local build of origin/dev (74336c9), same code. With the unmodified dev build the swipe picks the block every time (block bar "Block actions"); native text selection never won, in any speed or start point, keyboard down or up. What differs from what we wanted is the look: 2 CodeMirror handles, no highlight. That is kayg's screenshot, reproduced exactly (first image). The earlier fix never touched how a picked block is drawn.

before (dev) after (PR)
block bar shows 10/10 down, 10/10 up 10/10 down, 10/10 up
handles visible 2 every time 0
block tint + filled dot none 1 + 1 every time

The ten swipes: right and left on text, fast (0.15 s), start on a link, on the bullet, on the tag, on the second item, diagonal, on a paragraph. Each "up" swipe came after a tap that raised the keyboard.

Before: before
After: after
Frames of a swipe (block follows the finger, dot fills, springs back, tint and dots): frames

Still native (after build, simulator): tap places the caret (keyboard up); long-press selects text with the system menu ; double-tap selects the word ; a vertical drag scrolls (scrollTop 979, 0 prevented moves, no block); a drag from x=6 is the back swipe (touchstart seen, never claimed, page went back); the link chip opens its note. A tag in the text is not a link on dev either.

Not proven: whether kayg's phone ever starts a native selection before our claim; the simulator never did. If the screenshot was a native selection, send a screen recording. The claim logic is unchanged.

The sim run lines are in the PR comment below the gates. Raw per-swipe JSON, before/after, down/up (scratch, not committed): /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/ev/before-down.txt, before-up.txt, after-down.txt, after-up.txt.

Gates

  • svelte-check: 0 errors, 12 warnings (527 files)
  • packages/editor vitest: 117 passed (117)
  • touch-select: chromium-390 14 passed, webkit-390 14 passed
  • bar-focus/rest/stable/stays/taps + editor: chromium-390 40 passed, webkit-390 38 passed
  • phone-bars/edges/targets: chromium-390 399 passed; webkit-390 398 passed, 1 failed (an artifact folder deleted by my own parallel run: ENOENT); that test rerun alone: 1 passed
## Real-UIKit reproduction and fix (PR #523) **Finding.** iPhone 18 Pro simulator (iOS 27), Safari tab, raw touch events from XCUITest's event classes (no wait-for-idle). Production needs a passkey, so the "before" is a local build of origin/dev (74336c9), same code. With the unmodified dev build the swipe picks the block every time (block bar "Block actions"); native text selection never won, in any speed or start point, keyboard down or up. What differs from what we wanted is the look: 2 CodeMirror handles, no highlight. That is kayg's screenshot, reproduced exactly (first image). The earlier fix never touched how a picked block is drawn. | | before (dev) | after (PR) | |---|---|---| | block bar shows | 10/10 down, 10/10 up | 10/10 down, 10/10 up | | handles visible | 2 every time | 0 | | block tint + filled dot | none | 1 + 1 every time | The ten swipes: right and left on text, fast (0.15 s), start on a link, on the bullet, on the tag, on the second item, diagonal, on a paragraph. Each "up" swipe came after a tap that raised the keyboard. Before: ![before](https://git.kayg.org/attachments/ef46066b-70f9-49db-ae23-30c49e2cf446) After: ![after](https://git.kayg.org/attachments/61dd011e-8248-45bb-9d21-4856701f239a) Frames of a swipe (block follows the finger, dot fills, springs back, tint and dots): ![frames](https://git.kayg.org/attachments/7028a170-2526-4294-8b0c-7c07ad58725e) **Still native (after build, simulator):** tap places the caret (keyboard up); long-press selects text with the system menu ![](https://git.kayg.org/attachments/c4427eaf-7b83-4f0e-8aae-d07b94daf8d7); double-tap selects the word ![](https://git.kayg.org/attachments/96244996-54ca-45dd-983d-70c30c96d187); a vertical drag scrolls (scrollTop 979, 0 prevented moves, no block); a drag from x=6 is the back swipe (touchstart seen, never claimed, page went back); the link chip opens its note. A tag in the text is not a link on dev either. **Not proven:** whether kayg's phone ever starts a native selection before our claim; the simulator never did. If the screenshot was a native selection, send a screen recording. The claim logic is unchanged. **The sim run lines** are in the PR comment below the gates. Raw per-swipe JSON, before/after, down/up (scratch, not committed): /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/ev/before-down.txt, before-up.txt, after-down.txt, after-up.txt. ### Gates - svelte-check: 0 errors, 12 warnings (527 files) - packages/editor vitest: 117 passed (117) - touch-select: chromium-390 14 passed, webkit-390 14 passed - bar-focus/rest/stable/stays/taps + editor: chromium-390 40 passed, webkit-390 38 passed - phone-bars/edges/targets: chromium-390 399 passed; webkit-390 398 passed, 1 failed (an artifact folder deleted by my own parallel run: ENOENT); that test rerun alone: 1 passed
Author
Owner

Block-selection mockup: https://preview.calternal.cloud/select.html

Variants: right · left · indent · indent-noring. Knobs: &size=20|24|28, &tint=1|0. Swipe feel as #523 (32 px arms, block shows half the finger up to 56 px, tint 16%, radius 10), spring critically damped about 250 ms.

Sheet from the iPhone simulator (row 1 light, row 2 mid-swipe on the paragraph, row 3 dark; columns right, left, indent, indent-noring; 2 of 6 blocks picked):

select-compare

Block-selection mockup: https://preview.calternal.cloud/select.html Variants: [right](https://preview.calternal.cloud/select.html?v=right) · [left](https://preview.calternal.cloud/select.html?v=left) · [indent](https://preview.calternal.cloud/select.html?v=indent) · [indent-noring](https://preview.calternal.cloud/select.html?v=indent-noring). Knobs: `&size=20|24|28`, `&tint=1|0`. Swipe feel as #523 (32 px arms, block shows half the finger up to 56 px, tint 16%, radius 10), spring critically damped about 250 ms. Sheet from the iPhone simulator (row 1 light, row 2 mid-swipe on the paragraph, row 3 dark; columns right, left, indent, indent-noring; 2 of 6 blocks picked): ![select-compare](https://git.kayg.org/attachments/642c8301-5a35-43c6-b101-066c009eb343)
Author
Owner

Approved by kayg, 2026-10-17: select.html?v=left&size=24&tint=1. "this looks natural and great with the animation and motion you have picked! approved!"

The look:

  • 24 pt selection circles in the LEFT gutter. In selection mode every block shifts right, on the mockup spring (critically damped, about 250 ms, no overshoot).
  • Unselected blocks show a hollow ring; a selected block gets a filled accent circle with a white ✓.
  • The tinted highlight stays on.
  • The swipe follows the finger as in the mockup.

Next: build it into PR #523, replacing the right-side dot and the overshooting spring-back.

**Approved by kayg, 2026-10-17:** `select.html?v=left&size=24&tint=1`. "this looks natural and great with the animation and motion you have picked! approved!" The look: - 24 pt selection circles in the LEFT gutter. In selection mode every block shifts right, on the mockup spring (critically damped, about 250 ms, no overshoot). - Unselected blocks show a hollow ring; a selected block gets a filled accent circle with a white ✓. - The tinted highlight stays on. - The swipe follows the finger as in the mockup. Next: build it into PR #523, replacing the right-side dot and the overshooting spring-back.
Author
Owner

Approved look built into PR #523 (86fb22b, rebased on origin/dev 080c55e)

Values copied from select.css / Select.svelte of the mockup branch: 24 pt circle, 2 pt ring, circle left edge 14 pt from the screen edge, check = the app's icon (16 px, stroke 3), tint 16% accent, 10 px radius, 8 px past the text, 20 pt from the right edge, critically damped spring (omega 37, about 250 ms, no overshoot), swipe follows at half the distance (max 56, now also kept inside the page edge), arms at 32 px. Unlike the mockup: tints are 2 px shorter top and bottom so neighbours show a gap; the slide puts the text at 60 pt from the edge (mockup's absolute position), which is 40 pt on the app's 20 pt margin.

Side by side, same device scale (mockup left, app right, 2 blocks picked, light and dark): /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/r2/compare-v3.png. Full-resolution crops: /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/r2/zoom-v3.png. Attached:
Earlier before/after (native handles vs new look):

Computed values, iPhone simulator (402 pt wide, dpr 3), mockup vs app editor

mockup app
font-size / weight 17px / 460 17px / 460
line-height 26px 27.2px (1.6, look v2)
text left edge, rest 28 (mockup page pad) 46
text left edge, picked (first line) 81 86
bullet 6 px dot, +4 from content edge, text +21 5 px dot, marker box 26, text +26 (the editor's tree layout)
circle size / x 24 / 14 24 / 14
circle centre vs first line centre 130 vs 130 289.2 vs 289.2
block vertical padding 7 px each side line padding 1.94 px + 2 px tint trim

Text and font match; the app is not smaller. The mockup is a standalone page with its own bullet and indent, the app keeps the editor's tree layout, so I left those alone (changing bullets means changing tree lines for every note). Say if you want the editor's bullet moved to the mockup's.

One thing that does not match, as asked: in the mockup the right margin is always 60 pt, so the shift only translates. In the app the right margin is 20 pt, so a pure translate would push long lines 40 pt off the screen. So when picking starts the lines get a 40 px narrower column (once, together with the slide), and long lines rewrap once. Making it translate-only needs a permanent 60 pt right margin on phones for all notes: a layout change, so I did not do it. Tell me if you want it.

Gates (final code)

  • svelte-check: 0 errors, 12 warnings (543 files)
  • packages/editor vitest: 135 passed (135); tsc: no errors
  • touch-select: chromium-390 14 passed (27.6s), webkit-390 14 passed (1.6m)
  • bar-focus/rest/stable/stays/taps + editor: chromium-390 40 passed (2.4m), webkit-390 38 passed (9.8m)
  • phone-bars/edges/targets: chromium-390 399 passed (23.1m), webkit-390 399 passed (28.5m)
  • Simulator shots (light and dark: mid-swipe, one picked, two picked, before): /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/r2/shots/
## Approved look built into PR #523 (86fb22b, rebased on origin/dev 080c55e) Values copied from `select.css` / `Select.svelte` of the mockup branch: 24 pt circle, 2 pt ring, circle left edge 14 pt from the screen edge, check = the app's icon (16 px, stroke 3), tint 16% accent, 10 px radius, 8 px past the text, 20 pt from the right edge, critically damped spring (omega 37, about 250 ms, no overshoot), swipe follows at half the distance (max 56, now also kept inside the page edge), arms at 32 px. Unlike the mockup: tints are 2 px shorter top and bottom so neighbours show a gap; the slide puts the text at 60 pt from the edge (mockup's absolute position), which is 40 pt on the app's 20 pt margin. **Side by side, same device scale (mockup left, app right, 2 blocks picked, light and dark):** /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/r2/compare-v3.png. Full-resolution crops: /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/r2/zoom-v3.png. Attached: ![](https://git.kayg.org/attachments/ce3eeae5-7b62-462a-bf0a-a0ecd6026bbf) ![](https://git.kayg.org/attachments/3581cee8-f88b-4a36-92fb-e8facdb4b454) Earlier before/after (native handles vs new look): ![](https://git.kayg.org/attachments/1a2bc008-7894-4d27-8dd0-51365e4c1fb2) ![](https://git.kayg.org/attachments/12091c54-f50a-4526-990f-5f2a9762aca2) **Computed values, iPhone simulator (402 pt wide, dpr 3), mockup vs app editor** | | mockup | app | |---|---|---| | font-size / weight | 17px / 460 | 17px / 460 | | line-height | 26px | 27.2px (1.6, look v2) | | text left edge, rest | 28 (mockup page pad) | 46 | | text left edge, picked (first line) | 81 | 86 | | bullet | 6 px dot, +4 from content edge, text +21 | 5 px dot, marker box 26, text +26 (the editor's tree layout) | | circle size / x | 24 / 14 | 24 / 14 | | circle centre vs first line centre | 130 vs 130 | 289.2 vs 289.2 | | block vertical padding | 7 px each side | line padding 1.94 px + 2 px tint trim | Text and font match; the app is not smaller. The mockup is a standalone page with its own bullet and indent, the app keeps the editor's tree layout, so I left those alone (changing bullets means changing tree lines for every note). Say if you want the editor's bullet moved to the mockup's. **One thing that does not match, as asked:** in the mockup the right margin is always 60 pt, so the shift only translates. In the app the right margin is 20 pt, so a pure translate would push long lines 40 pt off the screen. So when picking starts the lines get a 40 px narrower column (once, together with the slide), and long lines rewrap once. Making it translate-only needs a permanent 60 pt right margin on phones for all notes: a layout change, so I did not do it. Tell me if you want it. ### Gates (final code) - svelte-check: 0 errors, 12 warnings (543 files) - packages/editor vitest: 135 passed (135); tsc: no errors - touch-select: chromium-390 14 passed (27.6s), webkit-390 14 passed (1.6m) - bar-focus/rest/stable/stays/taps + editor: chromium-390 40 passed (2.4m), webkit-390 38 passed (9.8m) - phone-bars/edges/targets: chromium-390 399 passed (23.1m), webkit-390 399 passed (28.5m) - Simulator shots (light and dark: mid-swipe, one picked, two picked, before): /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/r2/shots/
Author
Owner

Multi-toggle (PR #523, 482b162, on origin/dev bc7f401)

While blocks are selected, a swipe on another block or a tap on its circle adds it, or takes it out if it is already in. Bar says "N blocks"; Done or Esc clears all. Delete, duplicate and type changes work on the list (they need not touch). The 2-block hook is not in the PR.

iPhone simulator, real touch events: swipe the list item, swipe the second item (2 blocks), swipe the second item again (back to 1, "Block actions"):
Found on the simulator: a pulled block's ring was found by the circles' shared class, so it left the first circle filled. Fixed (follow.ts).
Shot: /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/r4/multi.png

Gates (final code):

  • svelte-check: 0 errors, 12 warnings (555 files)
  • editor vitest: 135 passed (135)
  • touch-select (incl. new add 2nd and 3rd block, remove one, Done, tap a circle, Esc): chromium-390 16 passed (1.1m), webkit-390 16 passed (1.0m)
  • bar-* + editor: chromium-390 40 passed (4.1m), webkit-390 38 passed (5.4m)
  • phone-bars/edges/targets: chromium-390 399 passed (17.3m), webkit-390 399 passed (30.8m)
## Multi-toggle (PR #523, 482b162, on origin/dev bc7f401) While blocks are selected, a swipe on another block or a tap on its circle adds it, or takes it out if it is already in. Bar says "N blocks"; Done or Esc clears all. Delete, duplicate and type changes work on the list (they need not touch). The 2-block hook is not in the PR. iPhone simulator, real touch events: swipe the list item, swipe the second item (2 blocks), swipe the second item again (back to 1, "Block actions"): ![](https://git.kayg.org/attachments/906e24b5-6918-4654-b1f4-5dfbfc1cc549) Found on the simulator: a pulled block's ring was found by the circles' shared class, so it left the first circle filled. Fixed (follow.ts). Shot: /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/r4/multi.png Gates (final code): - svelte-check: 0 errors, 12 warnings (555 files) - editor vitest: 135 passed (135) - touch-select (incl. new add 2nd and 3rd block, remove one, Done, tap a circle, Esc): chromium-390 16 passed (1.1m), webkit-390 16 passed (1.0m) - bar-* + editor: chromium-390 40 passed (4.1m), webkit-390 38 passed (5.4m) - phone-bars/edges/targets: chromium-390 399 passed (17.3m), webkit-390 399 passed (30.8m)
Author
Owner

Bullets as the approved mockup (PR #523, ec9954f, on origin/dev bc7f401)

A 6 px dot with the text 21 px in (was 5 px and 26 px), nested items too. cm.css: marker box 21 px (still grows with the checkbox at larger text), dot 6 px at 4 px, a number starts 4 px in, a to-do box keeps its size with a 3 px gap so its text starts at the same edge as the bullets' text. The tree lines meet the markers where the app's .page now says (bullet centre 6.5 px, half height 3 px, left edge 0, number centre 10 px); tree.css defaults stay for the mockup.

Before (left) / after (right), nested list with tree lines, same device scale, iPhone simulator: light dark
Numbers, nested bullet under a number, to-dos and a nested to-do:
Files: /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/r6/tree-light.png, tree-dark.png, tasks.png

Guides run through the dot centres, elbows stop just short of the child dots, text edges of bullets and to-dos line up (bullet and to-do text at the same x). Numbers keep their number inline as before. The 3 px gap between a to-do box and its text is tight; say if you want the box a little smaller.

Gates (final code)

  • svelte-check: 0 errors, 12 warnings (555 files)
  • editor vitest: 135 passed (135)
  • touch-select: chromium-390 16 passed (1.0m), webkit-390 16 passed (2.1m)
  • bar-* + editor + tree: chromium-390 46 passed (3.9m), webkit-390 44 passed (9.5m)
  • phone-bars/edges/targets: chromium-390 399 passed (27.3m), webkit-390 399 passed (42.4m)
## Bullets as the approved mockup (PR #523, ec9954f, on origin/dev bc7f401) A 6 px dot with the text 21 px in (was 5 px and 26 px), nested items too. `cm.css`: marker box 21 px (still grows with the checkbox at larger text), dot 6 px at 4 px, a number starts 4 px in, a to-do box keeps its size with a 3 px gap so its text starts at the same edge as the bullets' text. The tree lines meet the markers where the app's `.page` now says (bullet centre 6.5 px, half height 3 px, left edge 0, number centre 10 px); tree.css defaults stay for the mockup. Before (left) / after (right), nested list with tree lines, same device scale, iPhone simulator: light ![](https://git.kayg.org/attachments/40acb61a-9206-46be-8e79-8a74ae65dd6e) dark ![](https://git.kayg.org/attachments/317b8868-4ebc-4110-a192-420fe1acf850) Numbers, nested bullet under a number, to-dos and a nested to-do: ![](https://git.kayg.org/attachments/bb6da40c-bc40-4f3b-9316-5323aed14603) Files: /tmp/claude-1001/-home-kayg-Developer-calternal-cloud/204dcdd3-9d56-4d02-bbcc-2d778e727281/scratchpad/sim/e397/r6/tree-light.png, tree-dark.png, tasks.png Guides run through the dot centres, elbows stop just short of the child dots, text edges of bullets and to-dos line up (bullet and to-do text at the same x). Numbers keep their number inline as before. The 3 px gap between a to-do box and its text is tight; say if you want the box a little smaller. Gates (final code) - svelte-check: 0 errors, 12 warnings (555 files) - editor vitest: 135 passed (135) - touch-select: chromium-390 16 passed (1.0m), webkit-390 16 passed (2.1m) - bar-* + editor + tree: chromium-390 46 passed (3.9m), webkit-390 44 passed (9.5m) - phone-bars/edges/targets: chromium-390 399 passed (27.3m), webkit-390 399 passed (42.4m)
Author
Owner

Root cause and fix (PR: #576)

Cause. Both tints (the phone's picked look, picked.ts, and the desktop's Esc / Vim V look, selected.ts) were laid out from CodeMirror's height map (lineBlockAt(...).top/bottom). The height map does not know the vertical margin of a block widget. A note with tags has the tag chips row under its title (margin-bottom: 14px), and a daily note has the date heading widget (margin-bottom: 14px) plus the chips row. Everything below those widgets is drawn lower than the map says, so the tint landed that much too high: over the end of the previous block, short of the bottom of the selected one. My earlier checks used notes with no tags and no day heading, so the map and the page agreed.

Fix. One function, blockBox (packages/editor/src/blocks/box.ts), measures the block's own .cm-line elements as the browser drew them (first line's top, last line's bottom: wrapped rows, chips and tags all live inside the line), then adds the approved 8 px past the text sideways and the 2 px gap above and below. Space a line only has as padding (a heading's gap above it) is not covered. Phone tint, phone circles, the swipe pull tint and the desktop tint all use it. It measures again when the page lays out differently (resize, font load, wrapping, the picked slide), by a resize observer that exists only while a tint shows; no layout reads per frame.

Before / after (2x)

Phone, light: before-phone-light after-phone-light
Phone, dark: before-phone-dark after-phone-dark
Desktop (Vim V, j), light: before-desktop-light after-desktop-light
Desktop (Vim V, j), dark: before-desktop-dark after-desktop-dark
iPhone simulator, real wrapped log lines in a day note, two swipes (before, after): ios-sim-before-phone-light ios-sim-after-phone-light

## Root cause and fix (PR: https://git.kayg.org/kayg/calternal/pulls/576) **Cause.** Both tints (the phone's picked look, `picked.ts`, and the desktop's Esc / Vim `V` look, `selected.ts`) were laid out from CodeMirror's height map (`lineBlockAt(...).top/bottom`). The height map does not know the vertical margin of a block widget. A note with tags has the tag chips row under its title (`margin-bottom: 14px`), and a daily note has the date heading widget (`margin-bottom: 14px`) plus the chips row. Everything below those widgets is drawn lower than the map says, so the tint landed that much too high: over the end of the previous block, short of the bottom of the selected one. My earlier checks used notes with no tags and no day heading, so the map and the page agreed. **Fix.** One function, `blockBox` (`packages/editor/src/blocks/box.ts`), measures the block's own `.cm-line` elements as the browser drew them (first line's top, last line's bottom: wrapped rows, chips and tags all live inside the line), then adds the approved 8 px past the text sideways and the 2 px gap above and below. Space a line only has as padding (a heading's gap above it) is not covered. Phone tint, phone circles, the swipe pull tint and the desktop tint all use it. It measures again when the page lays out differently (resize, font load, wrapping, the picked slide), by a resize observer that exists only while a tint shows; no layout reads per frame. ## Before / after (2x) Phone, light: ![before-phone-light](https://git.kayg.org/attachments/e9aa2b11-20f5-4524-bf01-8f53e6fed9da) ![after-phone-light](https://git.kayg.org/attachments/78924b05-1bf0-4e6c-89f7-d2fec02ce90a) Phone, dark: ![before-phone-dark](https://git.kayg.org/attachments/ed14fe8c-8fe4-4bce-b489-3539ae0f2f3d) ![after-phone-dark](https://git.kayg.org/attachments/27f7b0fe-2033-4be7-83ec-8f07459097fd) Desktop (Vim `V`, `j`), light: ![before-desktop-light](https://git.kayg.org/attachments/19fc0d4b-d0e3-42bc-9b0a-c383425ddc40) ![after-desktop-light](https://git.kayg.org/attachments/dc1d2bee-10ef-4016-acc7-b1c76152045b) Desktop (Vim `V`, `j`), dark: ![before-desktop-dark](https://git.kayg.org/attachments/9883fe91-e11f-41b5-bcb6-104da8834f37) ![after-desktop-dark](https://git.kayg.org/attachments/92b209d8-c8ed-4e22-8705-b0f8c1021fda) iPhone simulator, real wrapped log lines in a day note, two swipes (before, after): ![ios-sim-before-phone-light](https://git.kayg.org/attachments/c0b4c256-152d-4366-b70a-3d4b758c484e) ![ios-sim-after-phone-light](https://git.kayg.org/attachments/f5363880-e47f-4fb4-aa97-f56e9a090d35)
Author
Owner

Round 3 of the selection mockup: card, no reflow, circles after the swipe. Branch issue/397-select-v2 (mockup, nothing merges until you say so). kayg's three asks and the lag report are all in.

Why the first mockup looked fine and production did not. The mockup moved blocks with a translate spring on short lines. Production's slide (picked.ts) writes a translate and a right margin on every line, every frame, and reads a box back for the tint, so the column narrows, long log lines rewrap, and the whole note is laid out 60 times a second. That is also the lag.

What changed (kayg's decisions)

  • The note sits on a card: 10 pt in from the sides, corners concentric with the phone's (sheet-radius.ts, copied unchanged from the chrome branch), on the photo backdrop.
  • No circle while the finger moves. The block follows with the approved resistance. On release past 32 pt it springs back and the circles then fade and scale in (small spring), 15 ms apart from the top. Under the threshold, or the wrong way, it springs back and nothing appears.
  • How Craft avoids the wrapping: the circles live in the card's padding, not in the text column. card-right copies that (swipe left), card-left mirrors it (swipe right). The padding is sized so a 24 pt circle keeps 8 pt clear of the text (tested at every block).
  • morph stays as the alternative: card-left's padding, but each bullet and checkbox grows in place into its circle, so lists keep their width. slide is dropped (see numbers).

What it costs in text width at 390 (today, no card: 354 for a paragraph, 335 for a list line). The card itself takes 20 (its two 10 pt insets), the circle's column 22 more.

look paragraph list line entering p50 / p95 frames over 20 ms frames in first 500 ms (of 30) layouts leaving, over 20 ms note
card-right 312 (-42) 293 (-42) 16.7 / 33.3 ms 5.6 % 25.9 1 1.6 % Craft's side
card-left 312 (-42) 293 (-42) 16.7 / 16.8 ms 3.7 % 26 1 3.8 % recommended: kayg's earlier side
morph 312 (-42) 312 (-23) 16.7 / 33.3 ms 6.3 % 22.6 1 9.9 % lists lose only the card
now (production, replicated) 334 (-20) 315 (-20) 83.3 / 150.1 ms 86.3 % 5.4 12.6 77 % 35 less once selecting, rewraps
slide (dropped) 334 315 16.7 / 33.4 ms 21.2 % 21.4 1 16.9 % translating a 300-row layer repaints it

Lag numbers. Chromium (software compositing) on the perf VM, 390 wide, 4x CPU throttle, a note of 300 log lines, 8 runs per look (about 200 frames each). The entering animation touches only opacity, scale and translate: no width, padding, margin or left per frame, no layout read per frame (one read, once, to place the stagger). The one slow frame in the card looks is the first, where the class flip restyles the card. now is production's mechanism replicated in the same page (not the app itself): every frame is a layout of the note, p50 83 ms. Drawing all 300 rows naively was slow (an earlier version toggled a class on every row: a frame of about 300 ms), so entering is now one attribute on the root and rows off the screen are skipped with content-visibility (the editor only draws the lines in view anyway).

Tests (Chromium and WebKit, 390 wide, 72 passing): no line changes its breaks between rest and selection, text does not move sideways, frames at 0/40/80/120/200/320 ms of entering and leaving on a frozen clock (no circle over a bullet or a word at any frame, same breaks, same widths, only calm properties animated), no circle or tint while the finger moves, short and wrong-way swipes show nothing, stagger at most 15 ms, text widths as in the table, circles on the first line's centre and on the bullet's (morph: the same centre at rest and selected), and a finger on a circle reaches its button. now passes its checks by failing the rules, which shows the detector works.

sheet

The same on the iPhone simulator (iOS 27 Safari, real WebKit, 402 wide): every look's lines are identical between rest and selection except now.

sim

Merge into chrome.html. Self-contained modules (all keyed by ?select=, ?v= still works): apps/mockup/src/select/looks.ts (the looks, lookFromQuery, swipe direction), selection.svelte.ts (state, springs, gesture, stagger), Ring.svelte, looks.css (geometry, circles, tint, motion), plus packages/ui/src/lib/sheet-radius.ts (identical to the chrome branch). The note's DOM contract is in the header of selection.svelte.ts: a root with data-look, data-mode, data-entering, rows .row[data-id] > .unit > (.hit > <Ring/>, .blk). Select.svelte, select.css, main.ts, select.html are the demo page only. Tests: tests/select.spec.ts and tests/select-helpers.ts (the frozen-clock helpers) move along; point open() at the chrome note.

**Round 3 of the selection mockup: card, no reflow, circles after the swipe.** Branch `issue/397-select-v2` (mockup, nothing merges until you say so). kayg's three asks and the lag report are all in. **Why the first mockup looked fine and production did not.** The mockup moved blocks with a translate spring on short lines. Production's slide (`picked.ts`) writes a translate *and* a right margin on every line, every frame, and reads a box back for the tint, so the column narrows, long log lines rewrap, and the whole note is laid out 60 times a second. That is also the lag. **What changed (kayg's decisions)** - The note sits on a **card**: 10 pt in from the sides, corners concentric with the phone's (`sheet-radius.ts`, copied unchanged from the chrome branch), on the photo backdrop. - **No circle while the finger moves.** The block follows with the approved resistance. On release past 32 pt it springs back and the circles then fade and scale in (small spring), 15 ms apart from the top. Under the threshold, or the wrong way, it springs back and nothing appears. - **How Craft avoids the wrapping:** the circles live in the card's padding, not in the text column. `card-right` copies that (swipe left), `card-left` mirrors it (swipe right). The padding is sized so a 24 pt circle keeps 8 pt clear of the text (tested at every block). - `morph` stays as the alternative: card-left's padding, but each bullet and checkbox grows in place into its circle, so lists keep their width. `slide` is dropped (see numbers). **What it costs in text width at 390** (today, no card: 354 for a paragraph, 335 for a list line). The card itself takes 20 (its two 10 pt insets), the circle's column 22 more. | look | paragraph | list line | entering p50 / p95 | frames over 20 ms | frames in first 500 ms (of 30) | layouts | leaving, over 20 ms | note | |---|---|---|---|---|---|---|---|---| | card-right | 312 (-42) | 293 (-42) | 16.7 / 33.3 ms | 5.6 % | 25.9 | 1 | 1.6 % | Craft's side | | card-left | 312 (-42) | 293 (-42) | 16.7 / 16.8 ms | 3.7 % | 26 | 1 | 3.8 % | recommended: kayg's earlier side | | morph | 312 (-42) | 312 (-23) | 16.7 / 33.3 ms | 6.3 % | 22.6 | 1 | 9.9 % | lists lose only the card | | now (production, replicated) | 334 (-20) | 315 (-20) | 83.3 / 150.1 ms | 86.3 % | 5.4 | 12.6 | 77 % | 35 less once selecting, rewraps | | slide (dropped) | 334 | 315 | 16.7 / 33.4 ms | 21.2 % | 21.4 | 1 | 16.9 % | translating a 300-row layer repaints it | **Lag numbers.** Chromium (software compositing) on the perf VM, 390 wide, 4x CPU throttle, a note of 300 log lines, 8 runs per look (about 200 frames each). The entering animation touches only opacity, scale and translate: no width, padding, margin or left per frame, no layout read per frame (one read, once, to place the stagger). The one slow frame in the card looks is the first, where the class flip restyles the card. `now` is production's mechanism replicated in the same page (not the app itself): every frame is a layout of the note, p50 83 ms. Drawing all 300 rows naively was slow (an earlier version toggled a class on every row: a frame of about 300 ms), so entering is now one attribute on the root and rows off the screen are skipped with `content-visibility` (the editor only draws the lines in view anyway). **Tests** (Chromium and WebKit, 390 wide, 72 passing): no line changes its breaks between rest and selection, text does not move sideways, frames at 0/40/80/120/200/320 ms of entering and leaving on a frozen clock (no circle over a bullet or a word at any frame, same breaks, same widths, only calm properties animated), no circle or tint while the finger moves, short and wrong-way swipes show nothing, stagger at most 15 ms, text widths as in the table, circles on the first line's centre and on the bullet's (morph: the same centre at rest and selected), and a finger on a circle reaches its button. `now` passes its checks by *failing the rules*, which shows the detector works. ![sheet](https://git.kayg.org/attachments/bb95f347-cb5e-402d-b085-9fe53d5c9102) **The same on the iPhone simulator (iOS 27 Safari, real WebKit, 402 wide):** every look's lines are identical between rest and selection except `now`. ![sim](https://git.kayg.org/attachments/6893d71d-2818-4c25-8f7e-e59b27ad3844) **Merge into chrome.html.** Self-contained modules (all keyed by `?select=`, `?v=` still works): `apps/mockup/src/select/looks.ts` (the looks, `lookFromQuery`, swipe direction), `selection.svelte.ts` (state, springs, gesture, stagger), `Ring.svelte`, `looks.css` (geometry, circles, tint, motion), plus `packages/ui/src/lib/sheet-radius.ts` (identical to the chrome branch). The note's DOM contract is in the header of `selection.svelte.ts`: a root with `data-look`, `data-mode`, `data-entering`, rows `.row[data-id]` > `.unit` > (`.hit` > `<Ring/>`, `.blk`). `Select.svelte`, `select.css`, `main.ts`, `select.html` are the demo page only. Tests: `tests/select.spec.ts` and `tests/select-helpers.ts` (the frozen-clock helpers) move along; point `open()` at the chrome note.
Author
Owner

Fix in PR (branch issue/397-no-text-sel)

Root cause. On an iPhone with the keyboard up, iOS (UIKit) paints the page's text selection itself: darker, ragged rectangles behind each line. It ignores ::selection (checked on the simulator: red and near-transparent styles change nothing), and CodeMirror's drawSelection does not draw the main range on iOS, so the existing CSS (.cm-selectionBackground, ::selection transparent) never touched it. A swiped block is still, underneath, a text selection across the block.

Fix. While blocks are picked and the editor has the keyboard, the editor's selection is parked as a caret (quiet in packages/editor/src/blocks/picked.ts). The pick lives on in the picked state and the app's block list, which every block action reads. The keyboard stays up. A tap, a key or an edit ends the pick as before. Desktop (Esc, Vim V) already painted nothing; unchanged.

Before (left) and after (right), real iOS 27 simulator, keyboard up, 3x crops (dark, light), plus desktop Esc (identical, as it was already right):

dark
light
desktop

Simulator checks on the fix: swipe a second block (both tinted, DOM selection a caret), Done button (text bar, caret kept, focus kept), keyboard stays up throughout.

## Fix in PR (branch `issue/397-no-text-sel`) **Root cause.** On an iPhone with the keyboard up, iOS (UIKit) paints the page's text selection itself: darker, ragged rectangles behind each line. It ignores `::selection` (checked on the simulator: red and near-transparent styles change nothing), and CodeMirror's `drawSelection` does not draw the main range on iOS, so the existing CSS (`.cm-selectionBackground`, `::selection` transparent) never touched it. A swiped block is still, underneath, a text selection across the block. **Fix.** While blocks are picked and the editor has the keyboard, the editor's selection is parked as a caret (`quiet` in `packages/editor/src/blocks/picked.ts`). The pick lives on in the `picked` state and the app's block list, which every block action reads. The keyboard stays up. A tap, a key or an edit ends the pick as before. Desktop (Esc, Vim `V`) already painted nothing; unchanged. **Before (left) and after (right), real iOS 27 simulator, keyboard up, 3x crops** (dark, light), plus desktop Esc (identical, as it was already right): ![dark](https://git.kayg.org/attachments/3adb534d-ae41-486c-a02c-f7ef26372af5) ![light](https://git.kayg.org/attachments/ffc65b39-c520-4062-ae90-c336a13a5a38) ![desktop](https://git.kayg.org/attachments/e5922c84-9e36-4855-b6ab-e693b079fb84) Simulator checks on the fix: swipe a second block (both tinted, DOM selection a caret), Done button (text bar, caret kept, focus kept), keyboard stays up throughout.
Author
Owner

Closing during the 26 Oct handover cleanup: Block swipe on iPhone and tint-only selection landed in dev (PRs #403, #576, #585, #586).

Closing during the 26 Oct handover cleanup: Block swipe on iPhone and tint-only selection landed in dev (PRs #403, #576, #585, #586).
kayg closed this issue 2026-10-26 08:46:20 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#397
No description provided.