fix a bug in bubble menu

This commit is contained in:
Philipp Kühn 2021-03-31 10:58:05 +02:00
parent df58611810
commit a90f08fb1c

View File

@ -53,7 +53,8 @@ export class BubbleMenuView {
}
focusHandler = () => {
this.update(this.editor.view)
// we use `setTimeout` to make sure `selection` is already updated
setTimeout(() => this.update(this.editor.view))
}
blurHandler = ({ event }: { event: FocusEvent }) => {
@ -76,10 +77,9 @@ export class BubbleMenuView {
update(view: EditorView, oldState?: EditorState) {
const { state, composing } = view
const { doc, selection } = state
const docHasChanged = !oldState?.doc.eq(doc)
const selectionHasChanged = !oldState?.selection.eq(selection)
const isSame = oldState && oldState.doc.eq(doc) && oldState.selection.eq(selection)
if (composing || (!docHasChanged && !selectionHasChanged)) {
if (composing || isSame) {
return
}