A platform for community discussion. Free, open, simple.
DEV: Fix prosemirror_links spec flakes (#40044)
Jarek Radoszd7e20df1acc8
diff --git a/frontend/discourse/app/static/prosemirror/extensions/link-toolbar.js b/frontend/discourse/app/static/prosemirror/extensions/link-toolbar.jsindex a10630ef5e2..7658ab9afe0 100644--- a/frontend/discourse/app/static/prosemirror/extensions/link-toolbar.js+++ b/frontend/discourse/app/static/prosemirror/extensions/link-toolbar.js@@ -114,23 +114,23 @@ class LinkToolbarPluginView {update(view) {this.#view = view;- if (view.state.selection instanceof NodeSelection) {- this.#resetToolbar();+ const markRange =+ !(view.state.selection instanceof NodeSelection) &&+ this.#utils.getMarkRange(+ view.state.selection.$head,+ view.state.schema.marks.link+ );++ if (markRange) {+ this.#updateLinkState(markRange);+ this.#displayToolbar();return;}- const markRange = this.#utils.getMarkRange(- view.state.selection.$head,- view.state.schema.marks.link- );-- if (!markRange) {+ // Don't tear down while a toolbar button is focused.+ if (!this.#menuInstance?.content?.contains(document.activeElement)) {this.#resetToolbar();- return;}-- this.#updateLinkState(markRange);- this.#displayToolbar();}#resetToolbar() {