Skip to content

Commit

Permalink
fix(LinkBubble): Prevent update race condition in read-only in Chrome
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Jan 23, 2024
1 parent 9d73a1b commit 840eeee
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/extensions/LinkBubblePluginView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class LinkBubblePluginView {

component = null
preventHide = false
hadUpdateFromClick = false
updateDebounceTimer = undefined
updateDelay = 250

Expand Down Expand Up @@ -126,6 +127,11 @@ class LinkBubblePluginView {
}

updateFromSelection(view) {
// Don't update directly after updateFromClick. Prevents race condition in read-only documents in Chrome.
if (this.hadUpdateFromClick) {
return
}

const { state } = view
const { selection } = state

Expand All @@ -151,6 +157,10 @@ class LinkBubblePluginView {

const shouldShow = linkNode?.marks.some(m => m.type.name === 'link')

this.hadUpdateFromClick = true
setTimeout(() => {
this.hadUpdateFromClick = false
}, 200)
this.updateTooltip(this.editor.view, shouldShow, linkNode, nodeStart)
}

Expand Down

0 comments on commit 840eeee

Please sign in to comment.