From b684ad963cea246cfb79c09034afc5c32a88f0f7 Mon Sep 17 00:00:00 2001 From: "Emilien Durieu (edu)" Date: Thu, 5 Aug 2021 14:02:11 +0000 Subject: [PATCH] [FIX] web_editor: detect spaces correctly Because of css rules, when a space was inserted (which is supposed to close the power box), it wouldn't be present in the innerText string. It was fixed by using the textContent property instead, which contains all the spaces, including the invisible ones. This might cause problems in some situation where the markup that the editor is modifying contains formatting spaces. task-2584101 closes odoo/odoo#74766 Signed-off-by: Antoine Guenet --- .../static/lib/odoo-editor/src/powerbox/Powerbox.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/lib/odoo-editor/src/powerbox/Powerbox.js b/addons/web_editor/static/lib/odoo-editor/src/powerbox/Powerbox.js index 2d572f3a120..200f661f28a 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/powerbox/Powerbox.js +++ b/addons/web_editor/static/lib/odoo-editor/src/powerbox/Powerbox.js @@ -170,7 +170,7 @@ export class Powerbox { this.show(); openOnKeyupTarget.removeEventListener('keyup', showOnceOnKeyup, true); initialTarget = openOnKeyupTarget; - this._initialValue = openOnKeyupTarget.innerText; + this._initialValue = openOnKeyupTarget.textContent; }; openOnKeyupTarget.addEventListener('keyup', showOnceOnKeyup, true); @@ -188,7 +188,7 @@ export class Powerbox { if (!initialTarget) return; const diff = patienceDiff( this._initialValue.split(''), - initialTarget.innerText.split(''), + initialTarget.textContent.split(''), true, ); this._lastText = diff.bMove.join(''); @@ -284,7 +284,7 @@ export class Powerbox { this._currentOpenOptions = openOptions; this._initialValue = ( this._currentOpenOptions.openOnKeyupTarget || this.options.editable - ).innerText; + ).textContent; this._currentFilteredCommands = this._currentOpenOptions.commands; this.render(this._currentOpenOptions.commands); }