Skip to content

[Bug]: Clicking the + block-edit button inside a list item opens the slash menu and immediately closes it (~20ms later), so nothing can be selected. #2472

Description

@Akshaychdev

Initial checklist

  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything (or linked relevant results below)

Affected packages and versions

in @milkdown/crepe (v7.21.3)

Link to runnable example

No response

Steps to reproduce

Steps to reproduce:

  1. 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()
  1. Place the cursor at the end of the list item text (Main).
  2. Hover the line to reveal the + (block-edit handle) button on the left, and click it.
  3. 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.
  4. 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

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions