[lexical-react] Revert revert: Remove deprecated ContextMenu, consolidate menu rendering with backward-compatible menuRenderFn#8199
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Playground Test ResultsTest 1: Slash Command Menu (
|
| Test | Result |
|---|---|
Slash commands (/) |
✅ PASS |
Emoji picker (:) |
✅ PASS |
| Emoji selection | ✅ PASS |
| Keyboard nav (ArrowDown) | ✅ PASS |
| Keyboard selection (Enter) | ✅ PASS |
| Escape dismissal | ✅ PASS |
Mentions (@) |
⏭️ Manual test needed |
| Context menu (right-click) | ⏭️ Pre-existing behavior, not a regression |
All 28 unit tests pass (pnpm run test-unit). Build, TypeScript, and lint all pass.
1b45c9a to
11350aa
Compare
Reapply "[lexical-react] [lexical-playground] Remove old ContextMenu, consolidate LexicalMenu render" (#7997) with backward compatibility: - Remove LexicalContextMenuPlugin (consolidated into LexicalNodeMenuPlugin) - Add default menu rendering in LexicalMenu when menuRenderFn is not provided - Make menuRenderFn optional on all plugin props for backward compatibility - Playground plugins use built-in default menu renderer instead of custom ones
Add 28 unit tests covering: - MenuOption class: key, ref, title, icon, setRefElement - MenuRenderFn type export validation - LexicalTypeaheadMenuPlugin export surface - LexicalNodeMenuPlugin export surface - Default menu rendering behavior
- MenuRenderFn: narrow matchingString from 'string | null' to 'string' (always called with empty string fallback, never null) - MenuOption: make title required 'string' (not optional, not JSX) for Flow invariant compatibility with www subclasses - MenuOption: remove icon from base class Flow type (www consumers use their own icon types like TintableIconSource, XDSSVGIconSource) - AutoEmbedOption: make title required, keep icon as React.MixedElement
708f6bc to
f39d079
Compare
|
I didn't do a super close look at the diff since an approval would trigger merge, do you want to look at this @ivailop7? At a glance it all seems good: the removed functionality has been deprecated for ~9 months, new test coverage, no suspicious changes (existing tests did not have to change) |
Summary
menuRenderFnis now optional onLexicalTypeaheadMenuPlugin,LexicalNodeMenuPlugin, andLexicalAutoEmbedPlugin. When omitted, a default consolidated renderer is used. Existing consumers passingmenuRenderFnare completely unaffected.LexicalContextMenuPlugin(LexicalNodeContextMenuPluginis the replacement since v0.32.0)MenuOptionclass now has optionaliconandtitleproperties for the default rendererMenuRenderFntype is re-exported from all plugin entry pointsPUNCTUATIONconstant kept for backward compatibilityBreaking Changes
LexicalContextMenuPluginis removed. UseLexicalNodeContextMenuPlugininstead (available since v0.32.0). See the playground ContextMenuPlugin for a migration example.menuRenderFnis now optional (previously required) onTypeaheadMenuPlugin,NodeMenuPlugin, andAutoEmbedPlugin. This is non-breaking for existing consumers — if you already passmenuRenderFn, nothing changes.Backward Compatibility
This PR was designed to be backward-compatible with existing consumers, including Meta's internal www codebase:
menuRenderFnwill continue to work unchanged — the prop is now optional, not removed.MenuRenderFntype remains exported from all entry points.PUNCTUATIONconstant is preserved.MenuOptionsubclass compatibility is maintained —iconandtitleare optional additions to the base class.LexicalContextMenuPlugin.menuRenderFnand are unaffected by this change.Test Plan
MenuOptionclass (key, ref, setRefElement, optional icon/title)MenuRenderFntype export validationLexicalMenudefault rendering (portal, items, selection, icon/title, empty state)LexicalMenucustom rendering viamenuRenderFn(selectedIndex, options, matchingString passthrough)LexicalTypeaheadMenuPluginwith and withoutmenuRenderFnLexicalNodeMenuPluginwith and withoutmenuRenderFnpnpm run ci-checkpasses (tsc, flow, prettier, lint)/) — menu renders with icons and titles, keyboard nav works, selection inserts node:) — menu renders with emoji icons + titles, selection inserts emoji