[FIX] web_editor: properly handle exec toolbar command after input click
When clicking on an input in the toolbar, the selection was lost and the commands could not be executed. This restores the latest selection in the editable in these cases. Part-of: odoo/odoo#119972
This commit is contained in:
@@ -1852,13 +1852,13 @@ export class OdooEditor extends EventTarget {
|
||||
bindExecCommand(element) {
|
||||
for (const buttonEl of element.querySelectorAll('[data-call]')) {
|
||||
buttonEl.addEventListener('click', ev => {
|
||||
const sel = this.document.getSelection();
|
||||
if (sel.anchorNode && ancestors(sel.anchorNode).includes(this.editable)) {
|
||||
this.execCommand(buttonEl.dataset.call, buttonEl.dataset.arg1);
|
||||
|
||||
ev.preventDefault();
|
||||
this._updateToolbar();
|
||||
if (!this.isSelectionInEditable()) {
|
||||
this.historyResetLatestComputedSelection(true);
|
||||
}
|
||||
this.execCommand(buttonEl.dataset.call, buttonEl.dataset.arg1);
|
||||
|
||||
ev.preventDefault();
|
||||
this._updateToolbar();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user