[FIX] web_editor: fix focus for some tools in Summernote

- Go to Project
- Open a project to display Tasks
- Switch to list view
- Click on create button
- On task form page, click nowhere. (It is important to not click on anything)
- On the taskbar of the WYSIWYG editor used for Description, click on one of the following actions:
    * Unordered list
    * Ordered list
    * Checklist
    * Table
    * Style
- The action will be applied to the "name" field (Task Title) and
  an error will prompt for Unordered list, Ordered list and Checklist actions
- If not, discard the form and retry by opening the form with create button

In this case, the WYSIWYG editor does not have the focus and try to execute
the tool action on the current focused element.

opw-2256835

closes odoo/odoo#52023

X-original-commit: eaa55ce3e806ad0d9609394309ff9d48b32bb73f
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
Anh Thao Pham (pta)
2020-05-27 18:13:00 +00:00
parent 9d40ec7d15
commit aca52baee3
@@ -1031,6 +1031,7 @@ options.styleTags = weDefaultOptions.styleTags;
$.summernote.pluginEvents.insertTable = function (event, editor, layoutInfo, sDim) {
var $editable = layoutInfo.editable();
$editable.focus();
var dimension = sDim.split('x');
var r = range.create();
if (!r) return;
@@ -1658,6 +1659,7 @@ function isFormatNode(node) {
$.summernote.pluginEvents.insertUnorderedList = function (event, editor, layoutInfo, type) {
var $editable = layoutInfo.editable();
$editable.focus();
$editable.data('NoteHistory').recordUndo($editable);
type = type || "UL";
@@ -1986,6 +1988,7 @@ $.summernote.pluginEvents.outdent = function (event, editor, layoutInfo) {
$.summernote.pluginEvents.formatBlock = function (event, editor, layoutInfo, sTagName) {
$.summernote.pluginEvents.applyFont(event, editor, layoutInfo, null, null, "Default");
var $editable = layoutInfo.editable();
$editable.focus();
$editable.data('NoteHistory').recordUndo($editable);
event.preventDefault();