Repository navigation
Description
Part of #499. Read the parent first. Step 5. Work on main.
Summary
- Today. Only the small grip starts a TOC drag. The heading title is a native link, so a press and move on the title starts the browser's own link drag (read from code). A lock that turns on during a drag does not stop it. A peer who deletes the dragged section leaves the drag running (both read from code).
- After. With a mouse, the whole heading row starts the TOC drag after the same 5px of travel, as in a file explorer. A click with less travel still opens the heading. A pen takes the mouse path in code. Whether a pen pans the list first is not verified (Step 0 checks it). With touch, only the grip starts a drag, so a swipe on a row scrolls the list. A lock or a peer delete ends the drag at once. Esc ends only the drag. A release after any cancel does not open the heading.
- Why. People used to file explorers grab the item name. Word's Navigation pane also moves a section by its heading (primary source: Microsoft support, "To move part of the document, select the heading and drag it to a new location."). Notion's help tells people to drag a block by its grip, so the peers do not agree. D30 flags this to the maintainer.
This issue adds no new visual, token or motion. It changes where a drag starts and how it ends.
Maintainer rulings that bind this issue
The full text of R1–R6 and the shared rules are on #499.
- R3. The Title row has no grip, nothing drops above it, and its level never changes. The new row activator must not give the Title row a drag start.
- R6. A set is one heading plus its whole subtree. A row drag picks up the same set as a grip drag does today.
- R1, R2, R4 and R5 do not change in this issue. Move a TOC section with its sub-headings and keep the Title fixed #500 and Drop a section onto a TOC heading to put it inside #508 own them.
Where this issue replaces the tracker text
This issue was checked against the code. Three rules here replace an older tracker draft. This body wins:
- The lock cancel event. Never send
keydownEscape withbubbles: true. That event reaches the chat composer'swindowlistener and can clear a comment draft. Usepointercancelwithbubbles: falseinstead (Step 4). - The Esc note. Never stop Esc in a capture-phase listener. A capture-phase stop on
windowordocumentruns before dnd-kit's own document listener, so Esc would stop cancelling the drag. Stop it in the bubble phase ondocumentinstead (Step 5). - D30 and
(pointer: fine). Never use that media query for D30. It reads only the primary pointer. Step 2 checks the pointer type on each event, which is how this issue meets D30.
Depends on / Blocks
- Depends on Rebuild the TOC drop hit test so folded rows and gaps land right #503. It rewrites the hit test and the rect cache in
useTocDrag.ts. This issue adds its cancel effects to the same hook, so it lands on top of that rewrite. - Depends on Add Move rows to Section options and open the menu from the grip #501. That issue makes a grip click open Section options. It also removes the grip on the Title row and on a locked pad. It adds the
isTitlefield toTocItem, and it reads the lock once inTocDesktopaseditingLocked. This issue reuses both values and reads no second copy. It must keep the grip click working and must not bring back a drag start on those rows. - Related: Announce TOC move results and return focus after a move #507 reads
cancelCauseRef(Step 4). It speaks a different line for a lock cancel and says nothing for a peer delete. This issue only records the cause. - Blocks Run the TOC move hallway test before drop inside ships #509. The hallway test records where each person grabs first: the grip, the title or the row.
Current behaviour
Code links are pinned to 85295b8cf2fc8f78efd5a3eaa4ecc05af413c2b2. dnd-kit lines refer to the installed @dnd-kit/[email protected] file dist/core.esm.js and the installed @dnd-kit/[email protected] file dist/sortable.esm.js. Neither has a permalink.
- The title is a native link with no
draggableattribute. The row renders<a href=… onClick=…>with nodraggable(TocRow.tsx:55-65; read from code). Links are draggable by default (primary source: MDNdraggable, "only text selections, images, and links can be dragged"). - Only the grip carries the drag listeners. The grip spreads
sortable.attributesandsortable.listeners(TocItemBody.tsx:121-133; read from code). So a press on the title creates no dnd-kit sensor. The browser link drag runs instead (inferred; Step 0 measures it). - A CSS guard sits on the wrong element.
.toc__item > .toc__rowsets-webkit-user-drag: noneon the rowdiv, not on the link (_tableOfContents.scss:81-88; read from code). Whether it stops the link drag in Chrome or Safari is not measured. Firefox does not support-webkit-user-drag(secondary / inferred). - The sensor is a plain
PointerSensorwith a 5px distance (useTocDrag.ts:73; read from code). The grip alone hastouch-action: none; the row has none (_tocDrag.scss:6-30; read from code).- The grip allows a WebKit native drag. It sets
-webkit-user-drag: element(_tocDrag.scss:29; read from code). No native grip drag should show, because a grip press creates a sensor, and the sensor cancelsdragstartonwindow(core.esm.jsline 1445; read from code). Step 0 checks this in Safari.
- The grip allows a WebKit native drag. It sets
- Text selection is blocked only after the drag starts.
user-select: noneis on.toc__list.is-draggingand on the body whileactiveIdis set (_tableOfContents.scss:35-61,useTocDrag.ts:75-92; read from code). dnd-kit clears a selection only when the drag activates (core.esm.jslines 1506-1512; read from code). Once the link cannot be dragged, the first 5px would select text (inferred). - The drag never reads the editing lock.
useTocDrag.tsand the rest ofcomponents/toc/never callselectDocumentEditingLocked(read from code: grep finds no hit). The selector is atisDocumentEditingLocked.ts:8-17. A lock that turns on mid-drag leaves the drag running (read from code; not measured). Move a TOC section with its sub-headings and keep the Title fixed #500 adds a'locked'refusal at drop time, so no transaction lands either way. - A peer delete leaves an empty drag running.
handleDragEndlooks the source up inflatItems. When it is gone, it only resets state (useTocDrag.ts:176-214; read from code). Until release, the overlay renders no card, becauseactiveItemis null (TocDesktop.tsx:132-164; inferred).buildTocItemsalso skips empty headings, so a peer who clears the title has the same effect (useToc.ts:62-92; read from code). - dnd-kit has no public cancel call (secondary / inferred). The
PointerSensorlistens on the activator's owner document. It ends the drag onpointercancel(lines 1441, 1611 and 1627) and on akeydownwhoseevent.codeis'Escape'(lines 1448 and 1595-1599). An event with onlykeyset does nothing (read from code). - Esc mid-drag can also clear the chat composer. The composer listens for
keydownonwindow, in the bubble phase, whatever has focus. On Escape it clears reply, edit and comment memory and empties the editor (useHandleEscKey.ts:44-73,:98-103; read from code). dnd-kit does not stop the event. So an Esc that cancels a TOC drag likely also drops a comment draft in docked chat (inferred; Step 0 measures it). - The Find bar is not at risk. Its Escape handler sits on the bar element and stops the event (
FindBar.tsx:222-227; read from code). A press on a TOC row moves focus out of the bar, so the bar does not see a drag's Esc (inferred). - A release after a cancel can still click the row. On a cancel, the sensor's
detach()removes thepointeruplistener at once. It removes the document click stopper 50ms later (core.esm.jslines 1474-1479; read from code). Theis-draggingclass leaves the list, so the rows take pointer events again (TocDesktop.tsx:106,_tableOfContents.scss:50-52; read from code). Today a cancel can start only from a grip press. With the row as activator, a release over the source title fires a nativeclickon the<a>.handleClickthen runsnavigateToHeading(item.id, { openChat: isDesktop })(TocItemBody.tsx:59-67; read from code). So the release would scroll the editor and open the heading chat (inferred; not measured). After Add Move rows to Section options and open the menu from the grip #501, a release on the grip would open Section options in the same way (inferred). TocItemhas no Title field. It holds onlyid,level,textContentandopen(types/toc.ts:4-9; read from code).buildTocItemsdoes not skip the first H1, so the Title is a normal row today (useToc.ts:72-88; read from code). The doc schema iscontent: 'heading block*', so the Title is always the doc's first child (title-document.ts:11-14; read from code).
Target behaviour
- Mouse. A press anywhere on a heading row arms the drag: the title, the empty row space, the level badge or the grip. After 5px of travel, the drag card shows. A release under 5px is a click, so the title still scrolls the editor to that heading.
- Pen. The sensor treats a pen like a mouse. The row has no
touch-action: none, so a pen may pan the list, and the browser then firespointercanceland ends the drag (secondary / inferred; not verified). Step 0 checks it. If a pen pans, treatpenliketouchinTocPointerSensor. - Not from the row's own buttons. A press that starts on the fold button, the chat trigger or the presence avatars never arms a row drag. A small wobble on the chevron must not start a drag.
- The grip. A press on the grip arms the drag for every pointer type. A grip click with no travel opens Section options (Add Move rows to Section options and open the menu from the grip #501).
- Touch. A touch on any part of the row other than the grip arms nothing. The list scrolls, as today.
- No browser native drag in Chrome, Safari or Firefox, from the title, from the header row or from the grip.
- No text highlight while a row press moves through its first 5px.
- Rows with no grip start no row drag. That is the Title row (R3) and every row on a locked pad.
- Lock mid-drag. When
editingLockedturns true during a drag, the drag ends at once with no transaction. - Peer delete mid-drag. When the source id leaves
flatItems, the drag ends at once. - Esc mid-drag ends the drag only. A reply, edit or comment draft in docked chat stays. The Find bar stays open.
- Release after a cancel. After Esc, a lock or a peer delete, the release of the same press clicks nothing. The editor does not scroll, no chat opens and no menu opens.
- Row cursor. No change. Rows keep the link
pointercursor at rest. The body showsgrabbingonce the drag starts, as today.
Micro-interactions
This issue owns step 2 of the Drag timeline on #499 and builds the lock and peer-delete cancels in step 9. Step 3 belongs to #503. The cancel fade and its words belong to #506 and #507.
| Moment | What the person sees | Timing |
|---|---|---|
| Press on a row (mouse) | Nothing changes. No text highlight. | Instant. |
| Move under 5px, then release | A normal click. The editor scrolls to the heading. | Existing. |
| Move 5px or more | The drag card shows at once; the body cursor is grabbing; the set stays as the ghost. |
Instant, no tween (existing). |
| Touch on a row (not the grip) | The list scrolls. | Browser native. |
| Esc, lock or peer delete | The drag ends; the card goes away; the ghost clears. | Instant today (dropAnimation={null}). #506 later adds the 80ms --motion-overlay-out fade. |
| Release after that cancel | Nothing. No scroll, no chat, no menu. | Instant. |
No new motion token, no new class and no new visual state. Reduced motion changes nothing here.
Implementation steps
Do the steps in this order. Read the files in Read first before you start.
Step 0. Measure today's behaviour (report only, does not gate the code)
Run make dev-local and open a pad with three headings in a visible tab at 1440×900. Use a real mouse.
- In Chrome, Safari and Firefox: press on a heading title and move 20px. Record whether a browser link drag image appears.
- In Safari: press on the grip and move 20px. Record whether a native drag image appears beside the TOC drag card.
- Open docked chat on a heading and start a comment or a reply. Start a grip drag in the TOC and press Esc. Record whether the comment or reply mode is cleared.
- Press on a grip, drag 20px, press Esc, then release over the same row's title. Record whether the editor scrolls or a chat opens. After Step 3 lands, repeat it with a press on the title.
- If a pen device is at hand (a Windows pen, or an iPad with Apple Pencil that shows the desktop TOC), press a row title with the pen and move 20px after Step 3 lands. Record whether the drag card shows or the list pans.
Post the results as a comment on this issue before you open a change. They confirm items 2, 3, 4, 9 and 11 of Current behaviour.
Step 1. Make the title link not draggable
In TocRow.tsx:55-65, set draggable={false} on the <a>. The header row shares TocRow, so its link changes too, which is correct.
With the row as activator, dnd-kit cancels dragstart on window once a sensor exists (core.esm.js line 1445; read from code). That covers a mouse press in every browser, Firefox included. draggable={false} covers every press that creates no sensor: touch on the title, and a press that TocPointerSensor rejects. Firefox ignores -webkit-user-drag, so the attribute is the only guard there. Keep the existing -webkit-user-drag: none rule; it does no harm. Leave the grip's -webkit-user-drag: element rule as it is; the sensor guard covers it (Current behaviour item 4).
Step 2. Add a TOC pointer sensor that checks the pointer type per event
Add apps/webapp/src/components/toc/dnd/tocPointerSensor.ts and export it from toc/dnd/index.ts. Use it in place of PointerSensor at useTocDrag.ts:73, with the same { distance: 5 }.
import { PointerSensor, type PointerSensorOptions } from '@dnd-kit/core'
import type { PointerEvent as ReactPointerEvent } from 'react'
import { TOC_CLASSES } from '../tocClasses'
const NO_ROW_START = `button, .avatar-group`
/** Mouse and pen start from the whole row; touch starts only from the grip. */
export class TocPointerSensor extends PointerSensor {
static activators = [
{
eventName: 'onPointerDown' as const,
handler: (
{ nativeEvent: event }: ReactPointerEvent,
{ onActivation }: PointerSensorOptions
) => {
if (!event.isPrimary || event.button !== 0) return false
const target = event.target as Element
const fromGrip = target.closest(`.${TOC_CLASSES.dragHandle}`)
if (!fromGrip && (event.pointerType === 'touch' || target.closest(NO_ROW_START))) {
return false
}
onActivation?.({ event })
return true
}
}
]
}PointerSensorOptionsis the type thatPointerSensor.d.tsgives the handler's second argument, and@dnd-kit/coreexports it (dist/index.d.tsline 8; read from code).- Never call
preventDefault()on thepointerdown. dnd-kit skips any event withdefaultPrevented(core.esm.jsline 3185; read from code), so the drag would never start. - Why a per-event check and not
(pointer: fine): that query tests only the primary pointer. Primary source: MDNpointer, "how accurate the primary pointing device is". A touch-screen laptop matches(pointer: fine), so a finger on a row would still arm a drag. This is how the step meets D30. - If Step 0 or the pen box shows that a pen pans the list, change the check to
event.pointerType === 'touch' || event.pointerType === 'pen'.
Step 3. Move the drag listeners from the grip to the row
TocRow. Add one optional prop,dragListeners?: DraggableSyntheticListeners(exported by@dnd-kit/core). Spread it on the rowdiv(TocRow.tsx:43-52).TocHeaderpasses nothing.TocItemBody. PassdragListeners={isDesktop ? sortable?.listeners : undefined}toTocRow(TocItemBody.tsx:149-174). Remove{...sortable.listeners}from the grip (:121-133). The grip sits inside the row, so itspointerdownreaches the row listener. Keep one listener spot; two spots would need thenativeEvent.dndKitguard (line 3185) to stay correct.- Keep
{...sortable.attributes}on the grip only. Never spread them on the row. They addrole="button",tabIndexand a role description, so the row would become a focusable button that holds a link and buttons. That is a nested-interactive failure. - No text selection. Add
select-noneto the rowclassNamefor desktop heading rows only (isDesktop && 'select-none'). Mobile rows and the header row keep their selection. - Rows with no grip.
listenersisundefinedwhen the draggable is disabled (core.esm.jsline 3446; read from code). TodayTocItemDesktop.tsx:26-29passes onlydisabled: collapsedIds.has(item.id). Set it todisabled: collapsedIds.has(item.id) || item.isTitle || editingLocked. This is the same rule that Add Move rows to Section options and open the menu from the grip #501 writes.item.isTitle. Use the field that Add Move rows to Section options and open the menu from the grip #501 adds toTocItem. That issue is a declared dependency, so this issue has no fallback.buildTocItemssets the field from doc child index 0, because its loop walksdoc.content.childCount(useToc.ts:72; read from code). The schema makes that child the Title (Current behaviour item 12). An empty Title is skipped atuseToc.ts:78(read from code). Then no row hasisTitle, and the next heading is a normal row.editingLocked. Add Move rows to Section options and open the menu from the grip #501 reads it once inTocDesktopand threads it to every row. This issue reads no second copy. Step 4.4 passes the same value intouseTocDragfor the cancel effect.- Why a boolean is safe for drop targets.
@dnd-kit/[email protected]maps a booleandisabledto{ draggable: value, droppable: false }(sortable.esm.jslines 628-633; read from code). So the Title row and the folded rows stay drop targets, as they are today. A drop just below the Title still works. Move a TOC section with its sub-headings and keep the Title fixed #500 refuses a drop above the Title. - Check that the Add Move rows to Section options and open the menu from the grip #501 rule is in place before you move the listeners. If a row only hides its grip, the row activator would reopen R3 and the lock.
- Grip click. Keep the click path that Add Move rows to Section options and open the menu from the grip #501 builds. A click under 5px never activates the sensor, so dnd-kit does not stop it (lines 1506-1512 run only on activation; read from code).
Step 4. End the drag on a lock or a peer delete, and swallow the release click
In useTocDrag.ts:
-
In
handleDragStart, store the owner document ofevent.activatorEvent?.targetin a ref. Fall back todocument. -
Add one helper. It sends
pointercancelto that document withbubbles: false:const cancelActiveDrag = () => ownerDocRef.current?.dispatchEvent(new PointerEvent('pointercancel', { bubbles: false }))
The
PointerSensorcallshandleCancelon it, and DndContext then callsonDragCancel(lines 1441 and 1627; read from code). No keyboard handler sees it, so the chat composer is safe.bubbles: falsekeeps it off thewindowlistener inComposerPrimaryAction.tsx. Check it in the browser.- Fallback. If a browser check shows that the event does not end the drag, send
new KeyboardEvent('keydown', { key: 'Escape', code: 'Escape', bubbles: false })to the same document.codeis required (line 1596).bubbles: falsekeeps it off the composer'swindowlistener.
- Fallback. If a browser check shows that the event does not end the drag, send
-
Record the cancel cause. Add
const cancelCauseRef = useRef<'locked' | 'source-gone' | null>(null). Set it on the line right before eachcancelActiveDrag()call in items 4 and 5. Clear it inresetState(useTocDrag.ts:103-106) withcancelCauseRef.current = null. ReturncancelCauseReffromuseTocDrag.- Reader. Announce TOC move results and return focus after a move #507 reads it in
handleDragCancel, beforeresetState()runs. SohandleDragCancelkeeps this order: the Announce TOC move results and return focus after a move #507 read, thenswallowNextClick(item 7), thenresetState(). - Esc and dnd-kit's own resize and
visibilitychangecancels never set it, so the reader seesnullfor them. resetStatealso runs after every drop, so a cause never outlives its drag.
- Reader. Announce TOC move results and return focus after a move #507 reads it in
-
Lock. Change the signature to
useTocDrag(items: TocItem[], editingLocked: boolean).TocDesktoppasses theeditingLockedvalue that Add Move rows to Section options and open the menu from the grip #501 reads. That read must come before theuseTocDragcall atTocDesktop.tsx:38. In an effect on[editingLocked, state.activeId], when both are set, setcancelCauseRef.current = 'locked', then callcancelActiveDrag(). -
Peer delete. In an effect on
[flatItems, state.activeId], whenactiveIdis set andflatItemshas no item with that id, setcancelCauseRef.current = 'source-gone', then callcancelActiveDrag(). Put it after the Rebuild the TOC drop hit test so folded rows and gaps land right #503 cache rebuild, so a rebuild never reads a dead source. -
The Move a TOC section with its sub-headings and keep the Title fixed #500
'locked'and'not-found'refusals still guard the drop. So a release that beats the effect still dispatches nothing. -
Swallow the click that the cancelled press makes. In
handleDragCancel(useTocDrag.ts:216), beforeresetState(), call one helper on the owner document. It covers Esc, the lock, the peer delete and dnd-kit's own resize andvisibilitychangecancels. A sketch:function swallowNextClick(doc: Document) { const stop = (e: MouseEvent) => { e.preventDefault() e.stopPropagation() } const done = () => { doc.removeEventListener('click', stop, true) doc.removeEventListener('pointerdown', done, true) } doc.addEventListener('click', stop, true) doc.addEventListener('pointerdown', done, true) doc.addEventListener('pointerup', () => setTimeout(done, 0), { capture: true, once: true }) }
- It uses the same document capture stop as dnd-kit's own click stopper (
core.esm.jsline 1506; read from code). React listens on the app root, so a document capture listener runs first. preventDefault()is required. The stop keeps the event from React, sohandleClicknever calls its ownpreventDefault(), and the<a href>would navigate.- The
pointerupplus one task clears it after the release. Thepointerdownclear covers a release outside the window, which sends nopointerup, so the next press is never swallowed. - A listener on the document keeps this inside the hook. The rows are memoized, and a ref in
useTocDragwould need a new prop on every row to reachhandleClick.
- It uses the same document capture stop as dnd-kit's own click stopper (
Step 5. Keep Esc inside the drag
In the activeId effect at useTocDrag.ts:75-92, add a keydown listener on document, in the bubble phase. On event.key === 'Escape', call event.stopPropagation(). Remove it in the same cleanup.
- Why the bubble phase on
document. dnd-kit's own Escape listener sits on the same document in the bubble phase (line 1448). dnd-kit adds it onpointerdown, before the drag activates. This effect runs after activation, so it runs second and the drag still cancels. Stopping there keeps the event offwindow, where the composer listens (inferred from listener order; check in the browser). - Never stop the event in a capture listener on
windowordocument. That stops it before dnd-kit's document listener, so Esc would no longer cancel the drag. - Do not edit
escapesOwnedElsewhereinuseHandleEscKey.ts. It is private to the composer. Using it would make chatroom code read TOC drag state.
Step 6. Docs
See Docs to update. Put them in the same change.
Step 7. Review checkpoint
Stop here. Run Verification, post the evidence on this issue, and wait for review. Do not commit, branch or push.
Out of scope
- The cancel fade and the "Move cancelled" phrase: Show where a moved section landed after a TOC move #506 and Announce TOC move results and return focus after a move #507.
- A long-press or touch drag on phones (D27, on [Tracking] Move TOC sections like folders: cascade, drop inside, and a menu path #499).
- A 24×24 grip hit area, and a grip shown at rest on coarse pointers (accessibility follow-up on [Tracking] Move TOC sections like folders: cascade, drop inside, and a menu path #499).
- The grip as a menu button, the Move rows, the grip rules and the
isTitlefield: Add Move rows to Section options and open the menu from the grip #501. - Hit zones, the rect cache and a deleted drop target: Rebuild the TOC drop hit test so folded rows and gaps land right #503.
- The planner refusals (
'locked','title-fixed','not-found'): Move a TOC section with its sub-headings and keep the Title fixed #500. - A
grabcursor on the row. It would be a new visual and needs a design-system ruling.
Decisions
Owner: the maintainer. The recommended answer comes first. None of these is a design-system ruling.
- D30. Where can a drag start? Recommended: with a mouse, the whole row starts a dnd-kit drag after the same 5px. A pen takes the same path unless the pen box shows it pans the list. With touch, only the grip starts one, so the list can still scroll. Always set
draggable={false}on the title link.- Reason: people used to file explorers grab the item name, and Word moves a section by its heading (primary source above). Today a grab on the name starts a native link drag.
- How the step meets it: D30 on [Tracking] Move TOC sections like folders: cascade, drop inside, and a menu path #499 splits mouse from touch. Step 2 checks
pointerTypeon each event, not the(pointer: fine)media query, because that query reads only the primary pointer. On a touch-screen laptop, a finger on a row still scrolls. - Cost: TOC titles can no longer be selected with the mouse. Copy link in Section options stays.
- Alternative: grip only, plus
draggable={false}on the title link. This matches Notion. Check either answer in Chrome, Safari and Firefox. - Peer check (
AGENTS.md:151):- Word: a drag starts from the heading (primary source: Microsoft support, "select the heading and drag it to a new location").
- Notion: the help page says to drag a block by its grip (primary source: Notion help, "Hover over any block and use the ⋮⋮ icon that appears as a handle to drag it around.").
- Google Docs: the document outline has no drag (secondary / inferred; no primary source found).
- The three products do not agree, so this is flagged to the maintainer under
AGENTS.md:151. If the maintainer keeps the row drag, the ruling comment records it as a deliberate exception.
Acceptance criteria
Every browser box uses a real mouse, a real pen or a real touch device, in a visible tab, at 1440×900, in light and in dark theme. cy.dragTocItem calls window._moveHeading and skips dnd-kit, so it proves nothing here.
- D30 is ruled before merge, and the ruling comment records the peer split.
- The Step 0 results are posted on this issue.
- In Chrome, Safari and Firefox, a press on a row title and 5px of travel starts the TOC drag card. No browser link-drag image appears.
- The same holds for a press on empty row space and on the level badge.
- In Safari, a grip drag shows only the TOC drag card, with no native drag image.
- A press on the fold chevron with 10px of travel starts no drag. A click on it still folds the section. The chat trigger behaves the same.
- A click on a row title with no travel scrolls the editor to that heading. A grip click with no travel opens Section options.
- No text highlight shows while a row press moves through its first 5px.
- The Title row starts no drag from any part of it. On a locked pad, no row starts a drag.
- With the Title text cleared, the Title has no row. The first row (the next heading) still starts a drag, and nothing drops above the Title.
- A drop just below the Title row still lands.
- With DevTools touch emulation, a swipe on a row scrolls the TOC list. A touch drag on the grip still moves a section.
- With a pen (a Windows pen, or an iPad with Apple Pencil that shows the desktop TOC), a press and move on a row title starts the TOC drag, and the list does not pan. If no pen device is at hand, say so on the issue and mark the pen path "not verified".
- Locking the pad mid-drag ends the drag at once, and no transaction lands. Check the document and the undo stack.
- With a DevTools breakpoint in
handleDragCancel, beforeresetState():cancelCauseRef.currentis'locked'after a lock cancel,'source-gone'after a peer delete, andnullafter Esc. AfterresetState(), it isnull. - A peer deleting the dragged section mid-drag ends the drag at once.
- Press on a title, drag 20px, press Esc, then release over the same title: the editor does not scroll and no chat opens. Repeat with the lock and the peer delete as the cancel. Repeat with a press on the grip: no Section options menu opens.
- After a cancel with a release outside the browser window, the next click on a row title still scrolls the editor.
- With a comment draft open in docked chat, Esc during a TOC drag ends the drag only. The comment mode and its text stay.
- With the Find bar open, Esc during a TOC drag ends the drag only. The Find bar stays open.
- After a mouse row drag ends, focus stays where the press put it, and no grip shows a focus ring (Chrome, Safari, Firefox). dnd-kit restores focus only after a keyboard drag (
core.esm.jsline 2707; read from code). - No new token, class recipe, motion value or z-tier lands.
- Static checks and the TOC Cypress spec pass. The
docs/DEMO.md,apps/webapp/CHANGELOG.mdandapps/webapp/CLAUDE.mdlines are in the same change.
Verification
Bun only.
- Static checks:
bun run check:push. It runsbun run lint,bun run lint:stylesandbun run typecheck. - Start the stack:
make dev-local. Read the WEBAPP port from themake dev-localoutput.scripts/run-tests.shdefaultsBASE_URLtohttp://localhost:3001(run-tests.sh:22; read from code), so always passBASE_URL. Below,<port>is that WEBAPP port. - E2E:
BASE_URL=http://localhost:<port> bash scripts/run-tests.sh --e2e --scope editor.apps/webapp/cypress/e2e/editor/toc/toc-render-and-drag.cy.jsmust still pass. - Browser, single user: open
http://localhost:<port>/editor?localPersistence=true&docName=toc-drag-start-lab. Type a Title and three H2 headings: "First Heading", "Second Heading" and "Third Heading", each with one line of body text. Give "Second Heading" one H3 child. Run the drag-start, click, chevron, selection, grip, touch and pen boxes in Chrome, Safari and Firefox. For the empty-Title box, clear the Title text. Check that the Title has no row, that the first row ("First Heading") still drags, and that a drop above it does not replace the Title. - Browser, one person, for the lock and peer-delete boxes. Use the playground, which exposes
window._storeandwindow._editor. Paste one line in the console, then start a row drag on "Second Heading" within 3 seconds and hold it.- Lock:
setTimeout(() => window._store.getState().setWorkspaceSetting('authorizedScope', 'readonly'), 3000). The drag must end when it fires. Keep holding, then release over the "Second Heading" title, and check the release-after-cancel box. Reload the page to clear the lock. - Peer delete:
setTimeout(() => { const ed = window._editor; ed.state.doc.forEach((n, pos) => { if (n.type.name === 'heading' && n.textContent === 'Second Heading') ed.view.dispatch(ed.state.tr.delete(pos, pos + n.nodeSize)) }) }, 3000). It removes the heading, so the source leavesflatItems, as a peer delete does. - Optional real-collab check: open one pad as its owner on a second device, such as a phone. Hold a row drag on the desktop as a signed-in non-owner. On the phone, turn on Read-only, or run Delete section. Sign in through the local inbox at
http://127.0.0.1:54324.
- Lock:
- Esc boxes: open docked chat on a heading and start a comment from a text selection. Then drag a TOC row and press Esc. For the release-after-cancel box, keep the button held after Esc and release over the same title.
- Before you trust a stuck drag, read
document.visibilityStatein the console. A hidden tab runs no animation frames. - Never run
next buildagainst the live dev server.
Tests. This issue adds no test by default (AGENTS.md §Test Policy). The change is event wiring with little branching, and the browser checks prove it. One test is allowed if the maintainer wants a pin for the shipped defect. Use cypress-real-events (already a dev dependency) in the TOC spec folder. Its failure mode: "a press and move on a TOC title starts a browser link drag instead of the TOC drag card." Prove it by sabotage: remove dragListeners from TocRow and see the test fail. Note that realMouseDown drives Chrome only.
Docs to update
docs/DEMO.md§Moving a section, grip sentences only (DEMO.md:224-231):- Line 224, "Drag the grip on a row up or down…": say a row, or its grip, starts a drag. Leave the sideways sentence to Set the drag level from the row above and indent the drop line #504.
- Line 231, "The grip is desktop only.": say a drag is desktop only, and that on a touch screen only the grip starts one.
- Leave the line 229 cascade sentence to Move a TOC section with its sub-headings and keep the Title fixed #500.
apps/webapp/CHANGELOG.md[Unreleased]: one### Changedline. For example: "A TOC drag now starts from the whole heading row with a mouse; a lock, a peer delete or Esc ends it at once."apps/webapp/CLAUDE.md§TOC And Heading Actions, the "TOC menus + drag" bullet (CLAUDE.md:311): add two sentences.TocPointerSensorstarts a drag from the whole row for a mouse or pen and from the grip for touch; the title link isdraggable={false}, and the row never takes the sortable attributes. A cancel swallows the click of the same press, so a release never opens the heading..cursor/docs/design-system.md: no change. No visuals change.
Read first
AGENTS.md§Test Policy, §Workflow And Review Expectations and §UI And Theme.apps/webapp/CLAUDE.md§TOC And Heading Actions and §Motion System (motion v1).apps/webapp/src/components/chatroom/CLAUDE.md§MessageComposer, the overlay-contention bullet on Escape..cursor/docs/design-system.md§Table of contents, the "drag states" row (design-system.md:401).CONTEXT.md§Pad outline.- [Tracking] Move TOC sections like folders: cascade, drop inside, and a menu path #499: the shared rules, the timeline and R1–R6.
Generated by Claude Code
Activity
HMarzban commentedon Nov 3, 2026
Status, 2026-11-03. Nothing from this issue is in the 2026-11-03 push (
a9b0c69e8..8e25e83df). A drag still starts from the grip only.Left:
HMarzban commentedon Nov 5, 2026
Closed by maintainer ruling 2026-11-05: the current TOC drag is the version we keep. It shipped in dd287cb and f571c08..e9d01ff (see #499). Reopen this if the need comes back.