Skip to content

fix: correct return type of getDefaultReactSlashMenuItems to include key#2416

Open
ysds wants to merge 1 commit intoTypeCellOS:mainfrom
ysds:fix/get-default-react-slash-menu-items-type
Open

fix: correct return type of getDefaultReactSlashMenuItems to include key#2416
ysds wants to merge 1 commit intoTypeCellOS:mainfrom
ysds:fix/get-default-react-slash-menu-items-type

Conversation

@ysds
Copy link
Contributor

@ysds ysds commented Feb 4, 2026

Summary

Fix incorrect return type of getDefaultReactSlashMenuItems() to properly include the key property.

Rationale

Items returned by getDefaultReactSlashMenuItems() actually contain a key property (inherited from getDefaultSlashMenuItems()), but the return type DefaultReactSuggestionItem[] omits key. This causes type errors when users try to access item.key:

getDefaultReactSlashMenuItems(editor).filter((item) => {
  console.log(item.key); // Error: Property 'key' does not exist
});

Changes

  • Updated return type of getDefaultReactSlashMenuItems() to include key property
  • Simplified return type of getPageBreakReactSlashMenuItems() by removing unnecessary Omit

Impact

  • Users can now access item.key without type errors
  • No breaking changes to runtime behavior

Testing

  • Type checking passes for all packages

Screenshots/Video

N/A (type-only change)

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

The return type was missing the `key` property, causing type errors when
accessing `item.key` on returned items.
@vercel
Copy link

vercel bot commented Feb 4, 2026

@ysds is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

>(
editor: BlockNoteEditor<BSchema, I, S>,
): (DefaultReactSuggestionItem & {
key: keyof Omit<Dictionary["slash_menu"], "page_break">;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct right? Aren't you marking all of the items as having a page_break key, when that is not actually the case. Shouldn't you change DefaultReactSuggestionItem instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look. I’ll check it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, Omit<Dictionary["slash_menu"], "page_break"> here represents "a union of keys excluding page_break", not "marking items as having a page_break key". This pattern follows the same approach used in the DefaultSuggestionItem.ts

I believe the current implementation is correct, but I do agree that modifying DefaultReactSuggestionItem could be a better approach.

However, changing DefaultReactSuggestionItem requires a deeper understanding of BlockNote's design decisions. The key property was removed from DefaultReactSuggestionItem in #652, but the PR doesn't explain why. I can only speculate on the reasons:

  • Potential conflicts with React's key prop
  • Custom suggestion items may not need a key

Making changes to DefaultReactSuggestionItem feels beyond my current understanding of the codebase. This PR at least addresses the immediate type issue.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants