-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Bug]: shouldShow broken in BubbleMenu extension from Vue 3 package #4870
Comments
Finally found a workaround to this issue. The underlying problem seems to stem from the For now, I'm using the following workaround in my
I've found importing Using I hope this helps others! |
I can confirm @mchestnut's workaround is valid, you must use the state from function isTextSelected({ editor }: { editor: Editor }) {
const {
state: {
doc,
selection,
selection: { empty, from, to },
},
} = editor.view // destructure from editor.view instead of just editor
const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(selection)
if (empty || isEmptyTextBlock || !editor.isEditable)
return false
return true
}``` |
…ue to reactiveState Fixes ueberdosis#4870
…ue to reactiveState Fixes ueberdosis#4870
…ue to reactiveState Fixes ueberdosis#4870
@mchestnut thanks for sharing your fix, I was pulling my hair out for ages! FWIW this fixes the same issue for @tiptap/react |
Which packages did you experience the bug in?
core, pm, starter-kit, vue-3
What Tiptap version are you using?
2.2.2
What’s the bug you are facing?
I'm noticing that the
shouldShow
callback is not functioning as expected in the Vue implementation of the Bubble Menu. When usingeditor.isActive
as part of the condition, the value returned fromisActive
doesn't represent that state that I expect.What browser are you using?
Chrome
Code example
https://stackblitz.com/edit/vitejs-vite-kgmrcn?file=src%2Fcomponents%2FTiptap.vue,package.json
What did you expect to happen?
Consider
shouldShow: ({ editor }) => editor.isActive('bold')
. I expect on first click into a bolded word that the bubble menu would become visible. However, it isn't and logging out the value ofisActive
in the method at that point returnsfalse
. But upon clicking again on any text (bold or not), the value then returnstrue
. It's as if theeditor
state inside the callback is from before the click is registered.Anything to add? (optional)
I do not see this same behavior in the vanilla JS implementation of Bubble Menu. I have not tested any other frameworks.
For comparison to the code example below, here is a working vanilla JS port of the same code.
https://stackblitz.com/edit/vitejs-vite-djsnpl?file=index.html,main.js&terminal=dev
Did you update your dependencies?
Are you sponsoring us?
The text was updated successfully, but these errors were encountered: