feat: Drag hendle menu delete button removes all other blocks in selection (BLO-1007)#2683
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughA functional change to the RemoveBlockItem click handler to support multi-block deletion based on editor selection state, paired with new end-to-end tests and snapshot fixtures validating the behavior across browsers. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 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 |
@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: |
@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: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/src/end-to-end/draghandle/draghandle.test.ts (1)
162-179: Consider extracting duplicated setup/selection steps into a helper.The block creation + multi-selection sequence is duplicated in both tests, which increases maintenance cost.
♻️ Proposed refactor
+async function setupBlocksAndSelectH3AndBullet(page: Page) { + await executeSlashCommand(page, "h1"); + await page.keyboard.type("Heading 1"); + await page.keyboard.press("Enter", { delay: 10 }); + await executeSlashCommand(page, "h2"); + await page.keyboard.type("Heading 2"); + await page.keyboard.press("Enter", { delay: 10 }); + await executeSlashCommand(page, "h3"); + await page.keyboard.type("Heading 3"); + await page.keyboard.press("Enter", { delay: 10 }); + await executeSlashCommand(page, "bullet"); + await page.keyboard.type("Bullet List"); + + await page.keyboard.down("Shift"); + await page.keyboard.press("ArrowUp"); + await page.keyboard.press("ControlOrMeta+ArrowLeft"); + await page.keyboard.up("Shift"); +}- await executeSlashCommand(page, "h1"); - await page.keyboard.type("Heading 1"); - ... - await page.keyboard.up("Shift"); + await setupBlocksAndSelectH3AndBullet(page);Also applies to: 192-208
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/src/end-to-end/draghandle/draghandle.test.ts` around lines 162 - 179, Extract the repeated block creation and multi-select steps into a helper function (e.g., setupThreeHeadingsAndBullet or createMultiBlockSelection) that calls executeSlashCommand and the keyboard sequence (typing headings/bullet and performing Shift+ArrowUp + ControlOrMeta+ArrowLeft) so both tests reuse it; update the tests "Delete button should delete..." and the other at lines 192-208 to call this helper instead of duplicating the sequence, keeping helper name and the keyboard actions consistent to preserve behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/src/end-to-end/draghandle/draghandle.test.ts`:
- Around line 162-179: Extract the repeated block creation and multi-select
steps into a helper function (e.g., setupThreeHeadingsAndBullet or
createMultiBlockSelection) that calls executeSlashCommand and the keyboard
sequence (typing headings/bullet and performing Shift+ArrowUp +
ControlOrMeta+ArrowLeft) so both tests reuse it; update the tests "Delete button
should delete..." and the other at lines 192-208 to call this helper instead of
duplicating the sequence, keeping helper name and the keyboard actions
consistent to preserve behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: de5cd189-ea45-4983-bc83-d8d133158830
📒 Files selected for processing (9)
packages/react/src/components/SideMenu/DragHandleMenu/DefaultItems/RemoveBlockItem.tsxtests/package.jsontests/src/end-to-end/draghandle/draghandle.test.tstests/src/end-to-end/draghandle/draghandle.test.ts-snapshots/draghandledeletehoveroutsideselection-chromium-linux.jsontests/src/end-to-end/draghandle/draghandle.test.ts-snapshots/draghandledeletehoveroutsideselection-firefox-linux.jsontests/src/end-to-end/draghandle/draghandle.test.ts-snapshots/draghandledeletehoveroutsideselection-webkit-linux.jsontests/src/end-to-end/draghandle/draghandle.test.ts-snapshots/draghandledeletemultiselection-chromium-linux.jsontests/src/end-to-end/draghandle/draghandle.test.ts-snapshots/draghandledeletemultiselection-firefox-linux.jsontests/src/end-to-end/draghandle/draghandle.test.ts-snapshots/draghandledeletemultiselection-webkit-linux.json
Summary
This PR changes the drag handle menu's delete button to delete not just the block it's attached to, but all blocks spanned by the selection, if the attached block is also spanned by the selection. Otherwise, the same behaviour as before applies.
Closes #2411
Rationale
This is more intuitive for users and makes it easier to delete many blocks at once.
Changes
RemoveBlockItem.Impact
N/A
Testing
Added e2e tests.
Screenshots/Video
N/A
Checklist
Additional Notes
N/A
Summary by CodeRabbit
Bug Fixes
Tests