Repository navigation
fix: do not treat blocks next to a gap cursor as selected - #3422
nperez0111 wants to merge 1 commit into
Conversation
|
Caution Review failedFailed to post review comments. GitHub was unavailable or timed out while CodeRabbit was posting the review. Please request a new review later if the pull request still needs one. Use Review summary publication is unconfirmed.
|
| Layer / File(s) | Summary |
|---|---|
Selected-block reporting packages/react/src/hooks/useSelectedBlocks.ts, packages/react/src/hooks/useSelectedBlocks.browser.test.tsx, tests/vite.config.browser.ts |
The hook returns an empty array for a gap cursor. Browser tests cover cursor movement, an empty result between images, and a block selection. The browser test configuration includes the new test. |
Block movement with a gap cursor packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts, packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts |
Movement commands without an explicit block identifier return for a gap cursor. Tests check that implicit moves leave the document and selection unchanged, while an explicit block move still occurs. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: matthewlipski, yousefed
Pre-merge checks: 
2 · 
1 · 
1
-
Failed checks: 1 warning · 1 inconclusive Passed checks: 2 passed-
Full details: Title check
-
Explanation
The title names the main change: blocks next to a gap cursor are no longer treated as selected. The raw summary shows useSelectedBlocks returns an empty array at a GapCursor, and selection-based block moves are skipped for a GapCursor, so the title matches the changeset.
Full details: Out of Scope Changes check
-
Explanation
The out-of-scope check passes. The moveBlocks.ts change makes moveSelectedBlocksAndSelection and moveBlocksInDirection return without moving when the selection is a GapCursor and no explicit block identifier is given. Explicit moves are unchanged. This follows from the same gap-cursor root cause: a block next to a gap cursor is not selected, so a selection-based move must not act on it. The moveBlocks.test.ts tests cover this behavior, and the useSelectedBlocks.browser.test.tsx test covers the hook. tests/vite.config.browser.ts only adds the new browser test to the allowlist. The raw summary shows no unrelated file changes.
-
Full details: Linked Issues check
-
Explanation
Issue
#3421has two reported APIs: useSelectedBlocks() and getTextCursorPosition().block. Both return the block below a gap cursor. The expected behavior is that no block is reported as selected at a gap cursor, or that the API exposes the gap-cursor state. The PR meets this for useSelectedBlocks(): the hook now returns [] when the selection is a GapCursor, and a browser test covers the empty result between two images. The PR does not meet it for getTextCursorPosition(). The PR description states that Core selection API contracts are unchanged, and the summary shows no change to getTextCursorPosition or to any gap-cursor exposure. The issue title and reproduction steps (step 3 logs both APIs) name getTextCursorPosition, so this requirement is unmet at the reviewed head. The summary does not show any code path that changes this behavior.Resolution
Change getTextCursorPosition() so that it does not report the block below a GapCursor as the cursor block. Alternatively, expose the gap-cursor state through the Core API so that consumers can detect it. Add a test that covers getTextCursorPosition() at a gap cursor between two non-inline blocks. If the maintainers decide to keep getTextCursorPosition() unchanged, they must narrow issue
#3421or record that decision explicitly. This is a scope decision, not a code change.
Full details: Description check
-
Explanation
The description states the fix (useSelectedBlocks returns [] at a gap, selection-based moves leave document and cursor unchanged) and links issue
#3421. It lacks the template's Rationale, Changes, Impact, Testing detail, Screenshots/Video, and Checklist sections. The template headings are not used, and the Summary is one short paragraph. The verification note is brief and does not describe the added tests.Resolution
Restructure the description to follow the template headings: Summary, Rationale, Changes, Impact, Testing, Screenshots/Video, Checklist, and Additional Notes. Add a Rationale that explains why a gap cursor should not select adjacent blocks. List the changes to moveBlocks.ts, useSelectedBlocks.ts, and the new tests. Note the impact on getTextCursorPosition(), which still reports the block below the cursor per issue
#3421. Describe the Chromium keyboard regression and the 75 Core tests in the Testing section. Mark the checklist items. State whether a screenshot or video applies.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
Fix failing CI checks
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit hops where cursor gaps appear,
No block is named when none is near.
The images stay in place,
Unless a block is named to move its space.
Tests watch each selection trail,
Then nibble carrots by the trail.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@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
@blocknote/xl-typst-exporter
commit: |
|
Fixes #3421.
A gap cursor does not select either adjacent block.
useSelectedBlocksnow returns[]at a gap, and selection-based block moves leave the document and cursor unchanged. Explicit block moves and Core selection API contracts are unchanged.Verified with the Chromium keyboard regression, 75 targeted Core tests, and type-aware lint.
Summary by CodeRabbit