fix: Suggestion menu behaviour (BLO-1283, BLO-955) - #2930
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughSuggestionMenu now supports multi-character trigger strings, prioritizes the longest matching trigger, and falls back to shorter triggers when necessary. Documentation and tests cover the updated matching behavior. ChangesSuggestion trigger matching
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/core/src/extensions/SuggestionMenu/SuggestionMenu.test.ts (1)
143-260: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the remaining trigger-entry paths.
Add regressions for replacing a non-empty selection with a trigger, and for typing when fewer preceding characters exist than the multi-character trigger requires. These are explicit PR objectives but are not exercised here.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/extensions/SuggestionMenu/SuggestionMenu.test.ts` around lines 143 - 260, Extend the SuggestionMenu tests around the existing multi-character trigger cases to cover replacing a non-empty text selection with the trigger and typing a multi-character trigger when fewer preceding characters are available than its length. Assert the expected plugin state and trigger behavior for each path, using the existing editor setup and cleanup conventions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/core/src/extensions/SuggestionMenu/SuggestionMenu.test.ts`:
- Around line 143-260: Extend the SuggestionMenu tests around the existing
multi-character trigger cases to cover replacing a non-empty text selection with
the trigger and typing a multi-character trigger when fewer preceding characters
are available than its length. Assert the expected plugin state and trigger
behavior for each path, using the existing editor setup and cleanup conventions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cd1bc157-08fc-44b1-bfb6-4ad81af58d4a
📒 Files selected for processing (3)
docs/content/docs/react/components/suggestion-menus.mdxpackages/core/src/extensions/SuggestionMenu/SuggestionMenu.test.tspackages/core/src/extensions/SuggestionMenu/SuggestionMenu.ts
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
|
Summary
This PR fixes 2 issues r.e. suggestion menus:
:andimg:, whenimg:is typed by the user, the:trigger suggestion menu may prioritized with no way to control this behaviour. Also, for longer triggers, checking if they are entered while the text cursor is at the start of the document will throw errors.Issue 1 is fixed using basically the same code as proposed in #2918. Issue 2 is fixed by removing a check which ensures the selection is empty before opening a suggestion menu. Given that this was an intentional check we were making, this is more a change in behaviour rather than a bug fix.
Both issues are included in this PR as they touch basically the exact same snippet of code.
Closes #2905
Closes #2090
Rationale
While a suggestion menu's
triggerCharactersuggests that a single character should be used, there is not much added complexity to make longer strings work.As for the suggestion menu opening while a selection is active, this seems to be more in-line with the behaviour of other products.
Changes
triggerCharacteralso accepts longer strings.Impact
N/A
Testing
Added unit tests.
Screenshots/Video
N/A
Checklist
Additional Notes
N/A
Summary by CodeRabbit
New Features
img:andref:.Documentation