Skip to content

fix(editor): clear slash-menu group headers when reverting the query#562

Merged
h4yfans merged 2 commits into
mainfrom
fix/slash-menu-ghost-groups
Jun 12, 2026
Merged

fix(editor): clear slash-menu group headers when reverting the query#562
h4yfans merged 2 commits into
mainfrom
fix/slash-menu-ghost-groups

Conversation

@h4yfans

@h4yfans h4yfans commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Fixes #520

Problem

The / block selector left stacked "BASIC BLOCKS" group headers behind when churning the query (type /t, delete the t, type another letter, repeat). They never cleared — even when nothing matched ("No items found").

Root cause

getItems built [...defaults, calloutItem, taskItem, ...aiItems]. Default items place the "Basic blocks" run near the front (before Advanced / Media / Headings / Others), while calloutItem (editor.callout.group = "Basic blocks") and taskItem (hardcoded "Basic blocks") are appended at the end → "Basic blocks" appears in two non-contiguous runs.

BlockNote's SuggestionMenu emits one <Label key={group}> per contiguous run, so the two runs produce two labels sharing key="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 from getItems. 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 helper
  • slash-menu-utils.test.ts — new test (4 cases, incl. the exact failing-before shape)
  • ContentArea.tsx — wrap the assembled array + one import

Verification

  • vitest --project renderer slash-menu-utils.test.ts → 4/4 pass
  • tsc -p tsconfig.web.json → exit 0
  • eslint (changed files) → 0 errors
  • Manual pnpm dev GUI repro: not yet run (fix is deterministic, unit-proven on the bug's exact shape)

…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.
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
memry-docs Ready Ready Preview, Comment Jun 12, 2026 11:04pm
memrynote-landing Ready Ready Preview, Comment Jun 12, 2026 11:04pm

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

React Doctor

React Doctor found 5 issues in 1 file.

Score Issues Errors Warnings Affected Files Scope
91 / 100 (Great) 5 0 5 1 3 files changed on fix/slash-menu-ghost-groups vs. main

Top Findings

Rule Severity Category Count
react-doctor/rerender-lazy-ref-init warning Performance 2
react-doctor/exhaustive-deps warning Bugs 1
react-doctor/prefer-tag-over-role warning Accessibility 1
react-doctor/button-has-type warning Bugs 1

View workflow run

Generated by React Doctor. Questions? Contact founders@million.dev.

@h4yfans h4yfans marked this pull request as ready for review June 12, 2026 22:56
@github-actions github-actions Bot added bug Something isn't working test labels Jun 12, 2026
@h4yfans h4yfans merged commit 4ce130f into main Jun 12, 2026
2 of 5 checks passed
@h4yfans h4yfans deleted the fix/slash-menu-ghost-groups branch June 12, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Block Selector doesn't fully clear

1 participant