Skip to content

Commit 23ee605

Browse files
authored
fix(SelectionContext): skip updates on attribute-only DOM mutations (#961)
1 parent a690b15 commit 23ee605

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • src/extensions/behavior/SelectionContext

src/extensions/behavior/SelectionContext/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,22 @@ class SelectionTooltip implements PluginSpec<PluginState> {
147147
const hideFromTr = pluginKey.getState(view.state)?.disabled;
148148

149149
// Don't show tooltip if editor not mounted to the DOM
150-
// or when view is out of focus
151-
if (hideFromTr || !view.dom.parentNode || !view.hasFocus()) {
150+
if (hideFromTr || !view.dom.parentNode) {
152151
this.tooltip.hide(view);
153152
return;
154153
}
155154

156155
const {state} = view;
157156
// Don't do anything if the document/selection didn't change
158-
if (prevState && prevState.doc.eq(state.doc) && prevState.selection.eq(state.selection))
157+
if (prevState && prevState.doc.eq(state.doc) && prevState.selection.eq(state.selection)) {
159158
return;
159+
}
160+
161+
// Don't show tooltip if editor out of focus
162+
if (!view.hasFocus()) {
163+
this.tooltip.hide(view);
164+
return;
165+
}
160166

161167
const {selection} = state;
162168
// Hide the tooltip if the selection is empty

0 commit comments

Comments
 (0)