Fix exitSuggestions() acting as trigger for other suggestions#7595
Open
oBusk wants to merge 3 commits intoueberdosis:mainfrom
Open
Fix exitSuggestions() acting as trigger for other suggestions#7595oBusk wants to merge 3 commits intoueberdosis:mainfrom
exitSuggestions() acting as trigger for other suggestions#7595oBusk wants to merge 3 commits intoueberdosis:mainfrom
Conversation
🦋 Changeset detectedLatest commit: bf04786 The changes in this PR will be included in the next version bump. This PR includes changesets to release 72 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
1 task
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an issue in @tiptap/suggestion where dispatching an exit transaction for one suggestion instance could unintentionally trigger matching/activation logic in other suggestion instances (Issue #7585).
Changes:
- Add a shared transaction meta flag to mark “exit” transactions and make other Suggestion instances skip match/activation logic for those transactions.
- Update
exitSuggestion()(and internal exit dispatch) to set the shared meta flag. - Add an integration test to ensure exiting one suggestion doesn’t activate another, and add a changeset for the patch.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/suggestion/src/suggestion.ts | Introduces a shared exit meta flag and short-circuits match logic for non-target Suggestion instances during exit transactions. |
| packages/suggestion/src/tests/suggestion.test.ts | Adds coverage to verify exitSuggestion() won’t re-activate another suggestion instance. |
| .changeset/violet-crabs-crash.md | Adds a patch changeset for the bugfix. |
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+430
to
+432
| // unchanged so we don't accidentally activate from the exit transaction. | ||
| if (transaction.getMeta(SUGGESTION_EXIT_META)) { | ||
| return prev |
| '@tiptap/suggestion': patch | ||
| --- | ||
|
|
||
| Fix exitSuggestion for one pluginKey can activate another suggestion pluginKey |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes Overview
Modifies so that suggestion trigger code never runs for a suggestion exit event, even if it's for another suggestion.
Implementation Approach
I wanted to look at how to fix this, added test to verify the issue, then added another global meta to be able to track it. If the global meta is present, skip running trigger check code.
Testing Done
Test verifies that triggering exit on one suggestion-instance does not activate another instance. Tested demos that suggestions still work.
Verification Steps
Verify that exiting suggestions programatically works as expected.
Additional Notes
I wanted to look at if this would be solvable in a nice way, but looking at it, we can't know it's an exit event without knowing about other suggestions, so using a global meta like this was the way I could see. It's not super pretty, understand if we want to say "it's not really a problem" and just close.
Checklist
Related Issues
This would close #7585