Skip to content
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: use correct state when doc changed externally #1646

Merged
merged 1 commit into from Aug 9, 2021

Conversation

dkrym
Copy link
Contributor

@dkrym dkrym commented Jul 27, 2021

There is a bug in suggestion plugin since Tiptap v1 when you use Collaboration and Mention together. It is bit edge case, but we actually ran into it in prod.

Open 2 editors (using collab)
Editor1 (user1): type some text and then enter Mention
Editor2 (user2): type/paste text anywhere before user1’s position
Editor1 (user1): confirms mention
Mention is at wrong position (replaces text at wrong position)

Reason:
When you use mention locally, from variables “handleStart, handleChange, handleExit“ only 1 is true (as it goes: start->change->...->change->exit).

When text in front of mention is changed in collab, it is not considered change (handleChange==false) as query is the same. Instead of it handleExit==true, handleStart==true and handleChange==false which cause that onStart is called with props from “prev” state instead of “next”.

When typing, the position is wrong by 1:
typing

When pasting text, it is wrong by the length of pasted text:
typing2

@philippkuehn philippkuehn merged commit 60606f9 into ueberdosis:main Aug 9, 2021
@philippkuehn
Copy link
Contributor

thanks!

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.

None yet

2 participants