mod icon indicating copy to clipboard operation
mod copied to clipboard

Mentions autocomplete sometimes adds an additional letter at the end

Open davidfurlong opened this issue 2 years ago • 11 comments

Repro steps: type "@d" select "@df". It inserts "@df f" instead of just "@df". This happens with other names too

davidfurlong avatar Oct 21 '23 13:10 davidfurlong

Can't seem to reproduce. What browser are you using?

stephancill avatar Oct 23 '23 11:10 stephancill

arc

davidfurlong avatar Oct 23 '23 11:10 davidfurlong

weird I can't repro every time, but I can still repro. Repro'd in safari as well - probs not a browser thing

davidfurlong avatar Oct 23 '23 11:10 davidfurlong

Consistent way of reproducing is to type @d - wait for the request to complete, then type f and click the result immediately

May require a patch to change the way that tiptap behaves. The range of text that is replaced is calculated and passed here https://github.com/ueberdosis/tiptap/blob/main/packages/suggestion/src/suggestion.ts#L102

stephancill avatar Oct 23 '23 14:10 stephancill

Reporting on my findings after doing some more digging. I think it would be useful to find where the suggestions plugin's state is updated and if that is somehow accessible from the mentions extension configuration. If we can trigger a state update on key press or when the mentioned user is selected it should solve our problem.

stephancill avatar Oct 24 '23 14:10 stephancill

wonder if we can repro on https://tiptap.dev/api/nodes/mention and if not (as I suspect), what the difference in the code is

davidfurlong avatar Oct 24 '23 16:10 davidfurlong

The difference is that suggestion.items in our code is async and in the example it’s not

stephancill avatar Oct 24 '23 16:10 stephancill

Struggling to reproduce this reliably. I think we can remove this as a requirement for releasing. I suspect it's this here: https://github.com/ueberdosis/tiptap/issues/2544

davidfurlong avatar Oct 24 '23 16:10 davidfurlong

there's a workaround here: https://github.com/ueberdosis/tiptap/issues/2592

davidfurlong avatar Oct 24 '23 16:10 davidfurlong

I don't think that this is related tbh.

You type @a, and the Suggestion utility will call onKeyDown, which in turn calls reactRenderer.ref?.onKeyDown(props), which crashes the application:

Our problem is with the Suggestion state not being updated in time. Renderer is working fine

Repro: https://www.loom.com/share/7ab5d51dcb3347e6ad9d12e8541fd6fc?sid=b79b84d8-ffd6-4a58-a422-62b49d426e7f

stephancill avatar Oct 25 '23 07:10 stephancill

ok yeah you're probably right

davidfurlong avatar Oct 25 '23 07:10 davidfurlong