[FIX] web_editor: re-implement focus method
Focus is sometimes called on the Wysiwyg class in Note. When the user use TAB to select the next field. Implementation was missing. closes odoo/odoo#69033 X-original-commit: 720c1f38a17ef54cf30e0a52bab5bceed70c2144 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -395,6 +395,25 @@ const Wysiwyg = Widget.extend({
|
||||
redo: function () {
|
||||
this.odooEditor.historyRedo();
|
||||
},
|
||||
/**
|
||||
* Focus inside the editor.
|
||||
*
|
||||
* Set cursor to the editor latest position before blur or to the last editable node, ready to type.
|
||||
*/
|
||||
focus: function () {
|
||||
if(!this.odooEditor.resetCursorOnLastHistoryCursor()) {
|
||||
// If the editor don't have an history step to focus to,
|
||||
// We place the cursor after the end of the editor exiting content.
|
||||
const range = document.createRange();
|
||||
const elementToTarget = this.$editable[0].lastElementChild ? this.$editable[0].lastElementChild : this.$editable[0];
|
||||
range.selectNodeContents(elementToTarget);
|
||||
range.collapse();
|
||||
|
||||
const selection = this.odooEditor.document.getSelection();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Start or resume the Odoo field changes muation observers.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user