Skip to content

Start a TOC drag from the whole row and cancel it safely #505

Closed as not planned

Description

@HMarzban

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.

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 keydown Escape with bubbles: true. That event reaches the chat composer's window listener and can clear a comment draft. Use pointercancel with bubbles: false instead (Step 4).
  • The Esc note. Never stop Esc in a capture-phase listener. A capture-phase stop on window or document runs before dnd-kit's own document listener, so Esc would stop cancelling the drag. Stop it in the bubble phase on document instead (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

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.

  1. The title is a native link with no draggable attribute. The row renders <a href=… onClick=…> with no draggable (TocRow.tsx:55-65; read from code). Links are draggable by default (primary source: MDN draggable, "only text selections, images, and links can be dragged").
  2. Only the grip carries the drag listeners. The grip spreads sortable.attributes and sortable.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).
  3. A CSS guard sits on the wrong element. .toc__item > .toc__row sets -webkit-user-drag: none on the row div, 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).
  4. The sensor is a plain PointerSensor with a 5px distance (useTocDrag.ts:73; read from code). The grip alone has touch-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 cancels dragstart on window (core.esm.js line 1445; read from code). Step 0 checks this in Safari.
  5. Text selection is blocked only after the drag starts. user-select: none is on .toc__list.is-dragging and on the body while activeId is set (_tableOfContents.scss:35-61, useTocDrag.ts:75-92; read from code). dnd-kit clears a selection only when the drag activates (core.esm.js lines 1506-1512; read from code). Once the link cannot be dragged, the first 5px would select text (inferred).
  6. The drag never reads the editing lock. useTocDrag.ts and the rest of components/toc/ never call selectDocumentEditingLocked (read from code: grep finds no hit). The selector is at isDocumentEditingLocked.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.
  7. A peer delete leaves an empty drag running. handleDragEnd looks the source up in flatItems. When it is gone, it only resets state (useTocDrag.ts:176-214; read from code). Until release, the overlay renders no card, because activeItem is null (TocDesktop.tsx:132-164; inferred). buildTocItems also skips empty headings, so a peer who clears the title has the same effect (useToc.ts:62-92; read from code).
  8. dnd-kit has no public cancel call (secondary / inferred). The PointerSensor listens on the activator's owner document. It ends the drag on pointercancel (lines 1441, 1611 and 1627) and on a keydown whose event.code is 'Escape' (lines 1448 and 1595-1599). An event with only key set does nothing (read from code).
  9. Esc mid-drag can also clear the chat composer. The composer listens for keydown on window, 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).
  10. 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).
  11. A release after a cancel can still click the row. On a cancel, the sensor's detach() removes the pointerup listener at once. It removes the document click stopper 50ms later (core.esm.js lines 1474-1479; read from code). The is-dragging class 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 native click on the <a>. handleClick then runs navigateToHeading(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).
  12. TocItem has no Title field. It holds only id, level, textContent and open (types/toc.ts:4-9; read from code). buildTocItems does not skip the first H1, so the Title is a normal row today (useToc.ts:72-88; read from code). The doc schema is content: '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 fires pointercancel and ends the drag (secondary / inferred; not verified). Step 0 checks it. If a pen pans, treat pen like touch in TocPointerSensor.
  • 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 editingLocked turns 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 pointer cursor at rest. The body shows grabbing once 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.

  1. In Chrome, Safari and Firefox: press on a heading title and move 20px. Record whether a browser link drag image appears.
  2. In Safari: press on the grip and move 20px. Record whether a native drag image appears beside the TOC drag card.
  3. 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.
  4. 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.
  5. 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
      }
    }
  ]
}
  • PointerSensorOptions is the type that PointerSensor.d.ts gives the handler's second argument, and @dnd-kit/core exports it (dist/index.d.ts line 8; read from code).
  • Never call preventDefault() on the pointerdown. dnd-kit skips any event with defaultPrevented (core.esm.js line 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: MDN pointer, "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

  1. TocRow. Add one optional prop, dragListeners?: DraggableSyntheticListeners (exported by @dnd-kit/core). Spread it on the row div (TocRow.tsx:43-52). TocHeader passes nothing.
  2. TocItemBody. Pass dragListeners={isDesktop ? sortable?.listeners : undefined} to TocRow (TocItemBody.tsx:149-174). Remove {...sortable.listeners} from the grip (:121-133). The grip sits inside the row, so its pointerdown reaches the row listener. Keep one listener spot; two spots would need the nativeEvent.dndKit guard (line 3185) to stay correct.
  3. Keep {...sortable.attributes} on the grip only. Never spread them on the row. They add role="button", tabIndex and a role description, so the row would become a focusable button that holds a link and buttons. That is a nested-interactive failure.
  4. No text selection. Add select-none to the row className for desktop heading rows only (isDesktop && 'select-none'). Mobile rows and the header row keep their selection.
  5. Rows with no grip. listeners is undefined when the draggable is disabled (core.esm.js line 3446; read from code). Today TocItemDesktop.tsx:26-29 passes only disabled: collapsedIds.has(item.id). Set it to disabled: 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.
  6. 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:

  1. In handleDragStart, store the owner document of event.activatorEvent?.target in a ref. Fall back to document.

  2. Add one helper. It sends pointercancel to that document with bubbles: false:

    const cancelActiveDrag = () =>
      ownerDocRef.current?.dispatchEvent(new PointerEvent('pointercancel', { bubbles: false }))

    The PointerSensor calls handleCancel on it, and DndContext then calls onDragCancel (lines 1441 and 1627; read from code). No keyboard handler sees it, so the chat composer is safe. bubbles: false keeps it off the window listener in ComposerPrimaryAction.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. code is required (line 1596). bubbles: false keeps it off the composer's window listener.
  3. Record the cancel cause. Add const cancelCauseRef = useRef<'locked' | 'source-gone' | null>(null). Set it on the line right before each cancelActiveDrag() call in items 4 and 5. Clear it in resetState (useTocDrag.ts:103-106) with cancelCauseRef.current = null. Return cancelCauseRef from useTocDrag.

  4. Lock. Change the signature to useTocDrag(items: TocItem[], editingLocked: boolean). TocDesktop passes the editingLocked value that Add Move rows to Section options and open the menu from the grip #501 reads. That read must come before the useTocDrag call at TocDesktop.tsx:38. In an effect on [editingLocked, state.activeId], when both are set, set cancelCauseRef.current = 'locked', then call cancelActiveDrag().

  5. Peer delete. In an effect on [flatItems, state.activeId], when activeId is set and flatItems has no item with that id, set cancelCauseRef.current = 'source-gone', then call cancelActiveDrag(). 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.

  6. 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.

  7. Swallow the click that the cancelled press makes. In handleDragCancel (useTocDrag.ts:216), before resetState(), call one helper on the owner document. It covers Esc, the lock, the peer delete and dnd-kit's own resize and visibilitychange cancels. 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.js line 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, so handleClick never calls its own preventDefault(), and the <a href> would navigate.
    • The pointerup plus one task clears it after the release. The pointerdown clear covers a release outside the window, which sends no pointerup, 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 useTocDrag would need a new prop on every row to reach handleClick.

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 on pointerdown, before the drag activates. This effect runs after activation, so it runs second and the drag still cancels. Stopping there keeps the event off window, where the composer listens (inferred from listener order; check in the browser).
  • Never stop the event in a capture listener on window or document. That stops it before dnd-kit's document listener, so Esc would no longer cancel the drag.
  • Do not edit escapesOwnedElsewhere in useHandleEscKey.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

Decisions

Owner: the maintainer. The recommended answer comes first. None of these is a design-system ruling.

  1. 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 pointerType on 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, before resetState(): cancelCauseRef.current is 'locked' after a lock cancel, 'source-gone' after a peer delete, and null after Esc. After resetState(), it is null.
  • 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.js line 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.md and apps/webapp/CLAUDE.md lines are in the same change.

Verification

Bun only.

  1. Static checks: bun run check:push. It runs bun run lint, bun run lint:styles and bun run typecheck.
  2. Start the stack: make dev-local. Read the WEBAPP port from the make dev-local output. scripts/run-tests.sh defaults BASE_URL to http://localhost:3001 (run-tests.sh:22; read from code), so always pass BASE_URL. Below, <port> is that WEBAPP port.
  3. 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.js must still pass.
  4. 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.
  5. Browser, one person, for the lock and peer-delete boxes. Use the playground, which exposes window._store and window._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 leaves flatItems, 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.
  6. 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.
  7. Before you trust a stuck drag, read document.visibilityState in the console. A hidden tab runs no animation frames.
  8. Never run next build against 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):
  • apps/webapp/CHANGELOG.md [Unreleased]: one ### Changed line. 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. TocPointerSensor starts a drag from the whole row for a mouse or pen and from the grip for touch; the title link is draggable={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


Generated by Claude Code

Activity

  1. added
    bug
    enhancement
    Toc
    on Oct 16, 2026
  2. added this to the v2.3.0 milestone on Oct 19, 2026
  3. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    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:

  4. HMarzban commented on Nov 5, 2026

    @HMarzban
    CollaboratorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DesktopTocUIbugenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions