fix(editor): clear slash-menu group headers when reverting the query#562
Merged
Conversation
…520) The "/" block selector left stacked "BASIC BLOCKS" group headers behind when churning the query (type /t, delete, type another letter, repeat). Root cause: getItems built [...defaults, calloutItem, taskItem, ...aiItems]. Default items place the "Basic blocks" group near the front, while the appended callout/task items (also group "Basic blocks") land at the back, so the group appears in two non-contiguous runs. BlockNote's SuggestionMenu emits one <Label key={group}> per contiguous run, producing two labels that share key="Basic blocks". Duplicate React keys break reconciliation as the filtered set changes, leaving ghost headers that never unmount. Add orderSlashMenuItemsByGroup to make each group contiguous (first-seen order preserved) before returning, so every group renders exactly once with a unique key. Callout and Task now fold into the single Basic blocks section.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
React Doctor found 5 issues in 1 file.
Top Findings
Generated by React Doctor. Questions? Contact founders@million.dev. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #520
Problem
The
/block selector left stacked "BASIC BLOCKS" group headers behind when churning the query (type/t, delete thet, type another letter, repeat). They never cleared — even when nothing matched ("No items found").Root cause
getItemsbuilt[...defaults, calloutItem, taskItem, ...aiItems]. Default items place the "Basic blocks" run near the front (before Advanced / Media / Headings / Others), whilecalloutItem(editor.callout.group= "Basic blocks") andtaskItem(hardcoded "Basic blocks") are appended at the end → "Basic blocks" appears in two non-contiguous runs.BlockNote's
SuggestionMenuemits one<Label key={group}>per contiguous run, so the two runs produce two labels sharingkey="Basic blocks". Duplicate React keys break reconciliation as the filtered set changes per keystroke, so stale label nodes are never unmounted and pile up.Fix
Add
orderSlashMenuItemsByGroup(pure helper) to make each group contiguous — first-seen group order and within-group order preserved — before returning fromgetItems. Each group now renders exactly once with a unique key. Callout and Task fold into the single "Basic blocks" section.slash-menu-utils.ts— new helperslash-menu-utils.test.ts— new test (4 cases, incl. the exact failing-before shape)ContentArea.tsx— wrap the assembled array + one importVerification
vitest --project renderer slash-menu-utils.test.ts→ 4/4 passtsc -p tsconfig.web.json→ exit 0eslint(changed files) → 0 errorspnpm devGUI repro: not yet run (fix is deterministic, unit-proven on the bug's exact shape)