diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/link.js b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js index 442ff8ef74f..aabc8a73212 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/link.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js @@ -127,12 +127,14 @@ const Link = Widget.extend({ this._updateOptionsUI(); this._adaptPreview(); - // ensure the focus in the first input of the link modal - setTimeout(()=> { - const firstInput = this.$('input:visible:first'); - firstInput.focus(); - firstInput.select(); - }, 0); + if (!this.options.noFocusUrl) { + // ensure the focus in the first input of the link modal + setTimeout(()=> { + const firstInput = this.$('input:visible:first'); + firstInput.focus(); + firstInput.select(); + }, 0); + } return this._super.apply(this, arguments); }, diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/link_popover_widget.js b/addons/web_editor/static/src/js/wysiwyg/widgets/link_popover_widget.js index 7a076adb3e5..415ae197829 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/link_popover_widget.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/link_popover_widget.js @@ -168,7 +168,10 @@ const LinkPopoverWidget = Widget.extend({ * @param {Event} ev */ _onEditLinkClick(ev) { - $('#toolbar #create-link').click(); + $('#wrapwrap').data('wysiwyg').toggleLinkTools({ + forceOpen: true, + link: this.$target[0], + }); ev.stopImmediatePropagation(); }, /** diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 326d24ad1dc..43f310890c7 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -796,6 +796,7 @@ const Wysiwyg = Widget.extend({ * @param {boolean} [options.forceOpen] default: false * @param {boolean} [options.forceDialog] force to open the dialog * @param {boolean} [options.link] The anchor element to edit if it is known. + * @param {boolean} [options.noFocusUrl=false] Disable the automatic focusing of the URL field. */ toggleLinkTools(options = {}) { if (this.snippetsMenu && !options.forceDialog) { @@ -804,7 +805,7 @@ const Wysiwyg = Widget.extend({ } if (options.forceOpen || !this.linkTools) { const $btn = this.toolbar.$el.find('#create-link'); - this.linkTools = new weWidgets.LinkTools(this, {wysiwyg: this}, this.odooEditor.editable, {}, $btn, options.link || this.lastMediaClicked); + this.linkTools = new weWidgets.LinkTools(this, {wysiwyg: this, noFocusUrl: options.noFocusUrl}, this.odooEditor.editable, {}, $btn, options.link || this.lastMediaClicked); const _onMousedown = ev => { if (!ev.target.closest('.oe-toolbar') && !ev.target.closest('.ui-autocomplete')) { // Destroy the link tools on click anywhere outside the