Skip to content
Snippets Groups Projects
Commit ce2ea13d authored by xO-Tx's avatar xO-Tx
Browse files

[FIX] web_editor: keep the observer active while adding link hint class

After preventing "async" code on link tools update in [1], the
`'link_tools'` test is still failing because of another race condition
issue:

The click on "save" after setting the link style to secondary triggers
an event handler that destroys the link tools widget (see `Wysiwyg` >
`destroyLinkTools()`), leading to calling the `_removeHintClasses()`
method first (both `_addHintClasses()` and `_removeHintClasses()` will
disable the editor observer while adding / removing the link hint
class to prevent their mutations to be recorded...).

Since the observer is inactive, the changes made to the link using the
link tools will not be processed, and the block will not be set as
`.o_dirty`.

As mentioned previously, (and starting from [2]) the editor observer is
inactive (while handling the `.oe_edited_link` class) in order to
prevent recording the mutations... But since [3], the editor had the
ability to prevent some classes (including `.oe_edited_link`) from being
taken into consideration in the `filterMutationRecords()` method...

The goal of this commit is to fix this race condition issue by simply
keeping the observer activated while handling the link hint class...

Remarks:

- These changes are supposed to fix the `link_tools` test that fails on
16.0+, but 15.0 was targeted here since the `.oe_edited_link` class is
ignored by the editor starting from 15.0 and also to prevent any future
issue linked to disabling the observer...

- Adding and removing the `active` class should not affect the history,
since it targets the `linktTools` toolbar button...

[1]: https://github.com/odoo/odoo/pull/109250/commits/f42715fdc89a6a88446c5f88ecec29e6a9c96fe1
[2]: https://github.com/odoo/odoo/pull/90064/commits/26377710a6e3ad61a8c266e9f7c0b8ade98f657d
[3]: https://github.com/odoo/odoo/commit/1c25ddb42393b136cac2a0ee0b9b7280fd803e7d



runbot-18747

closes odoo/odoo#125755

X-original-commit: 6a15cbe7
Signed-off-by: default avatarDavid Monjoie (dmo) <dmo@odoo.com>
parent 119f04d3
No related branches found
No related tags found
No related merge requests found
......@@ -386,19 +386,15 @@ const LinkTools = Link.extend({
* Add hint to the classes of the link and button.
*/
_addHintClasses () {
this.options.wysiwyg.odooEditor.observerUnactive("hint_classes");
this.$link.addClass('oe_edited_link');
this.$button.addClass('active');
this.options.wysiwyg.odooEditor.observerActive("hint_classes");
},
/**
* Remove hint to the classes of the link and button.
*/
_removeHintClasses () {
this.options.wysiwyg.odooEditor.observerUnactive("hint_classes");
$(this.options.wysiwyg.odooEditor.document).find('.oe_edited_link').removeClass('oe_edited_link');
this.$button.removeClass('active');
this.options.wysiwyg.odooEditor.observerActive("hint_classes");
},
//--------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment