From f769e4c80168d7b91ce0e149bded2429cddda41a Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 3 May 2023 17:44:10 +0200 Subject: [PATCH] wait #5904 @1.5 --- resources/linkeditor/js/linkeditor.form.js | 10 +++++++++- resources/linkeditor/js/linkeditor.links.js | 10 +++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/resources/linkeditor/js/linkeditor.form.js b/resources/linkeditor/js/linkeditor.form.js index 0e237a179..05dd2f2b0 100644 --- a/resources/linkeditor/js/linkeditor.form.js +++ b/resources/linkeditor/js/linkeditor.form.js @@ -158,7 +158,11 @@ LinkeditorForm.prototype = { }, focusAndSelectDestinationField: function () { - var f = $('#linkeditor-panel-form [name="to"]').get(0); + var f = $('#linkeditor-panel-form [name="to"]'); + if (f.length === 0) { + return; + } + f = f.get(0); f.focus(); f.select(); setTimeout(function () { @@ -194,6 +198,10 @@ LinkeditorForm.prototype = { this.initSelect2(); this.initSpectrum(); + + if ($(link).is('.new')) { + this.focusAndSelectDestinationField(); + } }, updateFormData: function (form) { diff --git a/resources/linkeditor/js/linkeditor.links.js b/resources/linkeditor/js/linkeditor.links.js index 7c86b7bbe..483200c9b 100644 --- a/resources/linkeditor/js/linkeditor.links.js +++ b/resources/linkeditor/js/linkeditor.links.js @@ -511,7 +511,7 @@ LinkeditorLinks.prototype = { createLinkDrag: function () { var link = this.duplicateLinkDrag({width: 0, height: 0}); - $(link).addClass('pendingCreate'); + $(link).addClass('pendingCreate').addClass('new'); this.deselectAllLinks(); this.selectLink($(link)); this.startResizeLink('se'); @@ -745,6 +745,9 @@ LinkeditorLinks.prototype = { this.setLastSelectedLink(l); } this.updateSelection(); + if ($(l).hasClass('new')) { + this.linkeditor.form.focusAndSelectDestinationField(); + } }, setLastSelectedLink: function (l) { @@ -779,12 +782,12 @@ LinkeditorLinks.prototype = { deselectAllLinks: function () { this.linkeditor.form.saveFormDataInLink(); this.linkeditor.form.updateLinkForm(); - $(".link.selected").removeClass('selected'); + $(".link.selected").removeClass('selected').removeClass('new'); this.updateSelection(); }, deselectLink: function (link) { - $(link).removeClass('selected'); + $(link).removeClass('selected').removeClass('new'); this.updateSelection(); }, @@ -937,6 +940,7 @@ LinkeditorLinks.prototype = { duplicateLinkClick: function () { let link = this.addLink(this._duplicateLink(), true); + $(link).addClass('new'); this.deselectAllLinks(); this.selectLink($(link)); -- 2.39.5