-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix suggestion collaboration bug #4380
Fix suggestion collaboration bug #4380
Conversation
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
bcaef5c
to
7e7ae19
Compare
Thank you for your contribution @fsvergara Sorry it took so long to get a review on this, I'm going to add to the beta |
@nperez0111 We found out that this fix introduced a bug that didn't exist before when using the suggestion utility with The newly introduced bug by this can be reproduced like this:
|
@rfgamaral I'd prefer to roll forward, will look into it tmrw There are too many changes queued up to be doing a patch release right now |
@fsvergara I wonder if this change (to latest tiptap version on develop) works for what you were running into? diff --git a/demos/src/Nodes/Mention/React/suggestion.js b/demos/src/Nodes/Mention/React/suggestion.js
index 554d9ee11..2695199d2 100644
--- a/demos/src/Nodes/Mention/React/suggestion.js
+++ b/demos/src/Nodes/Mention/React/suggestion.js
@@ -4,6 +4,7 @@ import tippy from 'tippy.js'
import MentionList from './MentionList.jsx'
export default {
+ allowSpaces: true,
items: ({ query }) => {
return [
'Lea Thompson',
diff --git a/packages/suggestion/src/suggestion.ts b/packages/suggestion/src/suggestion.ts
index 80744aaac..c0dd97808 100644
--- a/packages/suggestion/src/suggestion.ts
+++ b/packages/suggestion/src/suggestion.ts
@@ -194,10 +194,9 @@ export function Suggestion<I = any, TSelected = any>({
const started = !prev.active && next.active
const stopped = prev.active && !next.active
const changed = !started && !stopped && prev.query !== next.query
-
- const handleStart = started
+ const handleStart = started || moved
const handleChange = changed || moved
- const handleExit = stopped
+ const handleExit = stopped || moved
// Cancel when suggestion isn't active
if (!handleStart && !handleChange && !handleExit) { |
@nperez0111 Yes, that will fix it. Actually, just changing |
My understanding is that it would be okay to trigger more updates than needed (which would re-render a slash command), rather than forcing it to re-render and recreate from scratch by flagging the start and stop. |
@nperez0111 That's okay, rest up, and come back tomorrow energized 💪 Hopefully, you can figure it out tomorrow morning, and if you could cut a patch release, I'd really appreciate it. 🙏 This is blocking us from updating Tiptap to the latest version, which brings a couple of important fixes for us. |
@rfgamaral consider it done 😄 |
@rfgamaral 2.6.5 is out |
@nperez0111 This is much appreciated, thank you! |
@nperez0111 Sorry to bring this up again, but while doing tests on our side with the new version, we realized that it's still not working as it was before this PR. The remaining issue can be reproduced like this:
And while I was defining this test plan, I found yet another issue caused by this PR: firefox_mMo2z7HkRX.mp4When I selected all the text, and deleted the selection, the dropdown does not close. And yet another bug (they are all related to the same change): firefox_jmD6ENqxv8.mp4I always found the suggestion utility code a bit confusing, so I'm unsure if the best solution is to revert the code to what it was before this PR (and try to find a better solution for that issue), or try to keep rolling forward, and find a solution for all these issues. |
@rfgamaral I have too many things to do today so I won't be able to get to it until next week. My suggestion would be to attempt to add the same condition that I put at the Would be willing to take a PR for a fix sometime within the day |
@nperez0111 Yes, that solves all those issues I posted, and keeps the issue at hand also fixed 👍 Will open a quick PR. |
This is released with v2.7.0 https://github.com/ueberdosis/tiptap/releases/tag/v2.7.0 |
Please describe your changes
Fix a bug where the suggestion re-renders when someone is typing above the cursor while collaborating.
Here's a screencast explaining the bug and the code:
https://www.loom.com/share/bbb7e73feae44a8c8ebfcbae77ad3eb5?sid=8fd24818-0b3b-4cea-9a54-b7bcb017d682
How did you accomplish your changes
Change when onStart and onExit are called in the suggestion extension, so that they won't be called if we are just moving the suggestion but it will remain active.
How have you tested your changes
Used the changed version of the suggestion extension in our local environment, here's how it looks after the changes:
https://www.loom.com/share/facfc0b58a7a496199f2be07a8306969
How can we verify your changes
Remarks
[add any additional remarks here]
Checklist
Related issues