[FIX] web_editor: reorder the elements of the invisible elements panel
Steps to reproduce the bug: - Add a form snippet on the footer of the website page. - Change the visibility of the form snippet to "conditionally". - On the footer settings, deactivate the "Page Visibility". => The form snippet is still present on the "Invisible Elements" panel but clicking on it has no effects. Indeed, it is inside the footer which is hidden. The goal of this commit is to reorganize the "Invisible Elements" panel in order to better visualize the hierarchy between the different invisible elements. To do so, the list of the invisible snippet elements (`[...$invisibleSnippets]`) is scanned. Each invisible snippet that is the descendant of another is discarded of the list (to only keep the "root" ones) and a map is created with its `keys` set to invisible snippets that have invisible descendants. The `value` corresponding to an invisible snippet element is a list filled with all its descendant invisible snippets except those that have a closer invisible snippet ancestor. The list of the root snippets is then scanned. Each root snippet is inserted in the DOM as well as their descendant snippets found thanks to the newly created map. Note that thanks to this commit, another problem is solved: - Add a cookie bar on the website. - Add a Text-Image snippet and change its visibility to "conditionally". - Save and edit again. Note that the "Cookies Bar" is above the "Text- Image" on the "Invisible Elements" panel. - Click to display the cookie bar. => The order of the "Cookies Bar" and the "Text-Image" is switched on the "Invisible Elements" panel. Indeed, before this commit, the order of the snippets was influenced by the order of their snippet editor creation. Because this order was not always the same from one call to `_updateInvisibleDOM()` to another, a glitch could happen when toggling a snippet visibility. This is now fixed as the order of the invisible snippets in the "Invisible Elements" panel is determined either by their order in the list `rootInvisibleSnippetEls` or their order in the lists contained as value in the map `descendantPerSnippet`. task-3203914 Part-of: odoo/odoo#113549
Loading
Please register or sign in to comment