diff --git a/addons/web_editor/static/src/js/backend/html_field.js b/addons/web_editor/static/src/js/backend/html_field.js index e1b1e4d1f09..94cac573b21 100644 --- a/addons/web_editor/static/src/js/backend/html_field.js +++ b/addons/web_editor/static/src/js/backend/html_field.js @@ -228,6 +228,7 @@ export class HtmlField extends Component { res_model: this.props.record.resModel, res_id: this.props.record.resId, }, + fieldId: this.props.id, }; } /** diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index dede3258590..7017f05c0a9 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -759,6 +759,15 @@ const Wysiwyg = Widget.extend({ */ renderElement: function () { this.$editable = this.options.editable || $('
'); + + // We add the field's name as id so default_focus will target it if + // needed. For that to work, it has to already be editable but note that + // the editor is at this point not yet instantiated. + if (typeof this.options.fieldId !== 'undefined') { + this.$editable.attr('id', this.options.fieldId); + this.$editable.attr('contenteditable', true); + } + this.$root = this.$editable; if (this.options.height) { this.$editable.height(this.options.height);