diff options
| author | qsm-odoo <qsm@odoo.com> | 2019-10-23 13:48:22 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2019-11-18 09:56:07 +0000 |
| commit | 0cbc188a71b456486c60385da97ae2b445b35a96 (patch) | |
| tree | 229efba7515ccabadbd8877c0b83dd34dc214c71 /addons/web_editor/static/src | |
| parent | 466203311e25823f5570cde9108d21d419cd7ec4 (diff) | |
[FIX] web_editor: prevent focus change on recording undos
Part of https://github.com/odoo/odoo/pull/38959
task-2066614
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/rte.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js index 5c3fad24f64..7505e570626 100644 --- a/addons/web_editor/static/src/js/editor/rte.js +++ b/addons/web_editor/static/src/js/editor/rte.js @@ -423,6 +423,10 @@ var RTEWidget = Widget.extend({ * @param {boolean} internal_history */ historyRecordUndo: function ($target, event, internal_history) { + const initialActiveElement = document.activeElement; + const initialSelectionStart = initialActiveElement && initialActiveElement.selectionStart; + const initialSelectionEnd = initialActiveElement && initialActiveElement.selectionEnd; + $target = $($target); var rng = range.create(); var $editable = $(rng && rng.sc).closest('.o_editable'); @@ -442,6 +446,12 @@ var RTEWidget = Widget.extend({ console.log('error', e); } history.recordUndo($editable, event, internal_history); + + if (initialActiveElement && initialActiveElement !== document.activeElement) { + initialActiveElement.focus(); + initialActiveElement.selectionStart = initialSelectionStart; + initialActiveElement.selectionEnd = initialSelectionEnd; + } }, /** * Searches all the dirty element on the page and saves them one by one. If |
