From e881bc6284809ce3b29fff964b183df02aeb3ec4 Mon Sep 17 00:00:00 2001 From: Rodolpho Lima Date: Tue, 19 Sep 2023 16:00:18 +0200 Subject: [PATCH] [FIX] web_editor: Link(Dialog/Tools) label input field Before this commit, any changes made to label input field were lost when the LinkDialog or LinkTools component was re-rendered. This commit fixes it without leveraging OWL's reactivity/declarative approach, because most of the code in these components is imperative and not yet converted to the OWL paradigm, leaving such refactor to be done in the master branch. Part-of: odoo/odoo#136278 --- addons/web_editor/static/src/js/wysiwyg/widgets/link.js | 8 ++++---- addons/web_editor/static/src/xml/wysiwyg.xml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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 1fa9cbd00c7..7e6bc30013a 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/link.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js @@ -102,6 +102,7 @@ export class Link extends Component { this._updateOptionsUI(); this._setUrl({ shouldFocus: this.props.shouldFocusUrl }); + this.$el[0].querySelector('#o_link_dialog_label_input').value = this.state.originalText; } /** * @override @@ -526,8 +527,7 @@ export class Link extends Component { } const linkNode = this.$link[0] || this.state.range.cloneContents(); const linkText = linkNode.innerText; - this.state.initialContent = linkText.replace(/[ \t\r\n]+/g, ' '); - this.state.originalText = this.state.initialContent; + this.state.originalText = linkText.replace(/[ \t\r\n]+/g, ' '); if (linkNode instanceof DocumentFragment) { this.state.originalHTML = $('').append(linkNode).html(); } else { @@ -535,12 +535,12 @@ export class Link extends Component { } this.state.url = this.$link.attr('href') || ''; } else { - this.state.initialContent = this.state.initialContent ? this.state.initialContent.replace(/[ \t\r\n]+/g, ' ') : ''; + this.state.originalText = this.state.originalText ? this.state.originalText.replace(/[ \t\r\n]+/g, ' ') : ''; } if (!this.state.url) { - const urls = this.state.initialContent.match(OdooEditorLib.URL_REGEX_WITH_INFOS); + const urls = this.state.originalText.match(OdooEditorLib.URL_REGEX_WITH_INFOS); if (urls) { this.state.url = urls[0]; } diff --git a/addons/web_editor/static/src/xml/wysiwyg.xml b/addons/web_editor/static/src/xml/wysiwyg.xml index 49de60343b0..7e98650c1db 100644 --- a/addons/web_editor/static/src/xml/wysiwyg.xml +++ b/addons/web_editor/static/src/xml/wysiwyg.xml @@ -24,7 +24,7 @@
- +
@@ -129,7 +129,7 @@ Label
- +