Skip to content

fix: Allow adding block above table when it is the first block#2784

Open
mkcash wants to merge 1 commit into
TypeCellOS:mainfrom
mkcash:fix/table-first-block-add-above
Open

fix: Allow adding block above table when it is the first block#2784
mkcash wants to merge 1 commit into
TypeCellOS:mainfrom
mkcash:fix/table-first-block-add-above

Conversation

@mkcash
Copy link
Copy Markdown

@mkcash mkcash commented May 26, 2026

Fixes #2195

When a table is the first block in the document, the add block button now inserts the new block before it instead of after.

Summary by CodeRabbit

  • Bug Fixes
    • Improved block insertion logic in the Add Block button to correctly position new blocks based on their location in the document.

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

Someone is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 56fd8a30-9e2b-484b-bb83-d2e6e30e3001

📥 Commits

Reviewing files that changed from the base of the PR and between 118d8dc and 8f8b65e.

📒 Files selected for processing (1)
  • packages/react/src/components/SideMenu/DefaultButtons/AddBlockButton.tsx

📝 Walkthrough

Walkthrough

AddBlockButton's click handler now conditionally determines block insertion placement based on whether the selected block is the first block in the document, using getPrevBlock to check for a previous block and selecting "before" placement for first blocks or "after" otherwise.

Changes

Block Insertion Placement Fix

Layer / File(s) Summary
Conditional insertion placement
packages/react/src/components/SideMenu/DefaultButtons/AddBlockButton.tsx
AddBlockButton computes insertion placement using getPrevBlock to determine if the current block is first, selecting "before" for first blocks and "after" otherwise, enabling block insertion above first-block elements.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • nperez0111

Poem

🐰 A plus button's quest, now refined and true,
First blocks no longer blocked from blocks that brew,
Before and after, wisely placed,
Tables need not sit so displaced,
Above at last, the problem chewed!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing the ability to add a block above a table when it is the first block in the document.
Description check ✅ Passed The description is minimal but sufficient, identifying the linked issue and explaining the specific fix, though it does not follow the provided template structure.
Linked Issues check ✅ Passed The PR addresses the core requirement from issue #2195 by modifying the AddBlockButton to insert blocks before the first block instead of always inserting after.
Out of Scope Changes check ✅ Passed All changes in AddBlockButton.tsx are directly scoped to fixing the issue of adding blocks above a table when it is the first block.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 26, 2026

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@2784

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@2784

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@2784

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@2784

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@2784

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@2784

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@2784

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@2784

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@2784

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@2784

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@2784

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@2784

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@2784

commit: 8f8b65e

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot Add Block Above Table When Table is First Block

1 participant