feat: Enter moves selection to cell below in tables (BLO-1006)#2685
feat: Enter moves selection to cell below in tables (BLO-1006)#2685matthewlipski merged 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughChanges modify Enter/Shift+Enter behavior in table cells: Enter now moves the cursor to the cell below (if present) via table navigation utilities; Shift+Enter inserts a hard line break inside the current cell. End-to-end Playwright tests and JSON snapshots for Chromium, Firefox, and WebKit were added. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Editor
participant TableExtension
participant ProseMirror
User->>Editor: Press Enter (or Shift+Enter)
Editor->>TableExtension: keydown event -> invoke handler
TableExtension->>ProseMirror: check isInTable / selectionCell
alt Shift+Enter
TableExtension->>ProseMirror: insert hardBreak in current cell
ProseMirror-->>TableExtension: updated doc/selection
TableExtension-->>Editor: render/update
else Enter
TableExtension->>ProseMirror: compute nextCell (vertical)
alt nextCell exists
TableExtension->>ProseMirror: set selection to nextCell start (moveCellForward)
ProseMirror-->>TableExtension: updated doc/selection
TableExtension-->>Editor: scrollIntoView / render
else no nextCell
TableExtension-->>Editor: return false (no-op)
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/core/src/blocks/Table/TableExtension.ts`:
- Around line 50-63: The handler is consuming Enter even when nextCell($cell,
"vert", 1) is null; change the logic so you only claim the key event when a next
cell exists and you dispatched a transaction: call dispatch with
TextSelection.between($nextCell, moveCellForward($nextCell)).scrollIntoView()
only if $nextCell is truthy, and return true in that branch; otherwise return
false so the key falls back to the default behavior. Ensure you reference
selectionCell, nextCell, moveCellForward, TextSelection and dispatch when
updating the control flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 14ad8bff-c819-4262-800b-03acb165893c
📒 Files selected for processing (8)
packages/core/src/blocks/Table/TableExtension.tstests/src/end-to-end/tables/tables.test.tstests/src/end-to-end/tables/tables.test.ts-snapshots/enterMovesToCellBelow-json-chromium-linux.jsontests/src/end-to-end/tables/tables.test.ts-snapshots/enterMovesToCellBelow-json-firefox-linux.jsontests/src/end-to-end/tables/tables.test.ts-snapshots/enterMovesToCellBelow-json-webkit-linux.jsontests/src/end-to-end/tables/tables.test.ts-snapshots/shiftEnterNewLineInCell-json-chromium-linux.jsontests/src/end-to-end/tables/tables.test.ts-snapshots/shiftEnterNewLineInCell-json-firefox-linux.jsontests/src/end-to-end/tables/tables.test.ts-snapshots/shiftEnterNewLineInCell-json-webkit-linux.json
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
nperez0111
left a comment
There was a problem hiding this comment.
This works as I'd expect it, thanks @matthewlipski
Summary
This PR makes Enter move the selection to the cell below in a table much as Tab moves it to the cell right. Shift+Enter still creates a hard break as before.
Closes #2409
Rationale
This is more similar to how table keyboard navigation typically works in other apps.
Changes
See above.
Impact
N/A
Testing
Added e2e tests.
Screenshots/Video
N/A
Checklist
Additional Notes
N/A
Summary by CodeRabbit
New Features
Tests