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: prevent suggestions from being active when editor is readonly #2692

Conversation

scottsidwell
Copy link

Problem

The suggestions extension will continue to react to selection changes even when the editable is "readonly", which can lead to it showing a pop-up for text that start with the trigger character. This was discovered in #2680.

See the demo below:

Screen.Recording.2022-04-08.at.3.01.26.pm.mov

Fix

We need to ensure we don't attempt to detect a suggestion at the current selection when isEditable is false. The attached commit will fail-fast and cleanup any active suggestion state. Demo:

Screen.Recording.2022-04-08.at.3.07.36.pm.mov

@netlify
Copy link

netlify bot commented Apr 8, 2022

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 45990cd
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/62523da19ad7fd0009cbffeb
😎 Deploy Preview https://deploy-preview-2692--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@bdbch
Copy link
Contributor

bdbch commented Apr 9, 2022

Looks good to me. Thanks for your submission ☀️

@bdbch
Copy link
Contributor

bdbch commented Apr 9, 2022

It seems like there are linting issues in your code.

tiptap/packages/suggestion/src/suggestion.ts
Error:   172:38  error  Extra semicolon  semi

could you resolve them @scottsidwell?

@bdbch bdbch self-requested a review April 9, 2022 14:59
@bdbch bdbch self-assigned this Apr 9, 2022
@scottsidwell scottsidwell force-pushed the fix/prevent-active-suggestions-when-read-only branch from 16f277c to c680cca Compare April 9, 2022 22:37
@scottsidwell
Copy link
Author

@bdbch thanks for flagging, fixed :)

@scottsidwell scottsidwell force-pushed the fix/prevent-active-suggestions-when-read-only branch from c680cca to 45990cd Compare April 10, 2022 02:14
@bdbch
Copy link
Contributor

bdbch commented Apr 10, 2022

Thanks! Merged :)

@bdbch bdbch merged commit 45591ef into ueberdosis:main Apr 10, 2022
@sjdemartini
Copy link
Contributor

sjdemartini commented Apr 26, 2022

@bdbch Is there any chance a new version of @tiptap/suggestion could be published that contains this merged fix? I'm also encountering this bug and would really appreciate taking advantage of scottsidwell's change. 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.

3 participants