-
-
Notifications
You must be signed in to change notification settings - Fork 502
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: Link toolbar update error #1486
Conversation
…mouseover` handler
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -190,7 +190,7 @@ class LinkToolbarView implements PluginView { | |||
} | |||
} | |||
|
|||
update(view: EditorView, oldState?: EditorState) { | |||
update(view: EditorView, oldState?: EditorState, fromMouseOver = false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I crazy to think that no one else is calling this update method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this is part of the PluginView
spec from ProseMirror, it automatically gets called on state updates (https://prosemirror.net/docs/ref/#state.PluginView). It's just harder to see that since in our case the view does a lot of stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I guess normally you'd pass in a plain object, so the fact that we're using a class also obfuscates things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh ok. Eh, this definitely is a hack. But, I think it is okay for now
This PR fixes an bug with the link toolbar, where
mouseHoveredLinkMark
may be defined even when the mouse cursor isn't hovering any links. This is because the plugin would check if a link is currently hovered by the keyboard or mouse on every state update. State updates may cause the link under the mouse cursor move or be removed outright (such as moving blocks up & down, where it's briefly removed when replacing blocks). However, as nomouseover
event is fired,mouseHoveredLinkMark
doesn't get cleared and so an error is thrown if the link doesn't exist.Therefore, this PR changes the behaviour so that only
keyboardHoveredLinkMark
is considered when updating the link toolbar, unless the update was explicitly called by themouseover
handler.Closes #1479