Initial checklist
Affected packages and versions
in @milkdown/crepe (v7.21.3)
Link to runnable example
No response
Steps to reproduce
Steps to reproduce:
- Create a default Crepe editor with default features (no custom config needed):
import { Crepe } from '@milkdown/crepe'
import '@milkdown/crepe/theme/common/style.css'
import '@milkdown/crepe/theme/frame.css'
const crepe = new Crepe({
root: document.querySelector('#app'),
defaultValue: '- Main\n',
})
crepe.create()
- Place the cursor at the end of the list item text (Main).
- Hover the line to reveal the + (block-edit handle) button on the left, and click it.
- Observe: the slash/block menu flashes open for an instant, then closes immediately (roughly a 20ms window), so no menu item can be clicked or selected.
- For comparison, do the same on a plain paragraph (not inside a list item) — the menu opens and stays open normally.
Root cause (from tracing the source):
packages/crepe/src/feature/block-edit/handle/index.ts onAdd() inserts a new paragraph and calls menuAPI.show(pos), opening the menu.
- That transaction also triggers
packages/crepe/src/feature/block-edit/menu/index.ts's debounced (debounce: 20) shouldShow recheck via the SlashProvider's onUpdate.
shouldShow calls isInList(selection) (utils/checker.ts), which returns true whenever the selection's grandparent node is list_item - which is exactly the state left behind by the + button's own insert when clicked inside a list item. shouldShow returns false, hiding the menu it just opened.
isInList appears intended to suppress the typed / trigger while composing list text, but it also incorrectly fires against the button's own programmatic menuAPI.show() call.
Expected behavior
Clicking + inside a list item opens the block menu and keeps it open until the user picks an item or dismisses it, same as for a paragraph.
Actual behavior
The menu closes itself almost immediately after opening, making it impossible to use + inside list items.
Runtime
Chrome
OS
Linux
Build and bundle tools
Vite
Initial checklist
Affected packages and versions
in @milkdown/crepe (v7.21.3)
Link to runnable example
No response
Steps to reproduce
Steps to reproduce:
Root cause (from tracing the source):
packages/crepe/src/feature/block-edit/handle/index.tsonAdd()inserts a new paragraph and callsmenuAPI.show(pos), opening the menu.packages/crepe/src/feature/block-edit/menu/index.ts's debounced (debounce: 20)shouldShowrecheck via the SlashProvider's onUpdate.shouldShowcallsisInList(selection)(utils/checker.ts), which returns true whenever the selection's grandparent node islist_item- which is exactly the state left behind by the + button's own insert when clicked inside a list item. shouldShow returns false, hiding the menu it just opened.isInListappears intended to suppress the typed / trigger while composing list text, but it also incorrectly fires against the button's own programmaticmenuAPI.show()call.Expected behavior
Clicking + inside a list item opens the block menu and keeps it open until the user picks an item or dismisses it, same as for a paragraph.
Actual behavior
The menu closes itself almost immediately after opening, making it impossible to use + inside list items.
Runtime
Chrome
OS
Linux
Build and bundle tools
Vite