Skip to content

Commit dfb7375

Browse files
AlessandroLupoloco-odoo
authored andcommitted
[FIX] html_builder: toggle visibility of nested invisible elements
1 parent eaf9e3d commit dfb7375

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

addons/html_builder/static/src/sidebar/invisible_elements_panel.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,29 @@ export class InvisibleElementsPanel extends Component {
5555
// └ descendantInvisibleSnippet
5656
// └ descendantOfDescendantInvisibleSnippet
5757
// └ etc...
58-
const createInvisibleEntries = (snippetEls, isDescendant) =>
58+
const createInvisibleEntries = (snippetEls, parentEl = null) =>
5959
snippetEls.map((snippetEl) => {
6060
const descendantSnippetEls = descendantPerSnippet.get(snippetEl);
6161
// An element is considered as "RootParent" if it has one or
6262
// more invisible descendants but is not a descendant.
6363
const invisibleElement = {
6464
snippetEl: snippetEl,
6565
name: getSnippetName(snippetEl),
66-
isRootParent: !isDescendant && !!descendantSnippetEls,
67-
isDescendant,
66+
isRootParent: !parentEl && !!descendantSnippetEls,
67+
isDescendant: !!parentEl,
6868
isVisible: snippetEl.dataset.invisible !== "1",
6969
children: [],
70+
parentEl,
7071
};
7172
if (descendantSnippetEls) {
72-
invisibleElement.children = createInvisibleEntries(descendantSnippetEls, true);
73+
invisibleElement.children = createInvisibleEntries(
74+
descendantSnippetEls,
75+
invisibleElement
76+
);
7377
}
7478
return invisibleElement;
7579
});
76-
this.state.invisibleEntries = createInvisibleEntries(rootInvisibleSnippetEls, false);
80+
this.state.invisibleEntries = createInvisibleEntries(rootInvisibleSnippetEls);
7781
}
7882

7983
toggleElementVisibility(invisibleEntry) {
@@ -97,10 +101,10 @@ export class InvisibleElementsPanel extends Component {
97101
this.toggleElementVisibility(child);
98102
}
99103
});
100-
} else if (invisibleEntry.parents && !invisibleEntry.parents.isVisible) {
104+
} else if (invisibleEntry.parentEl && !invisibleEntry.parentEl.isVisible) {
101105
// When toggling the visibility of an element to "Show", also toggle
102106
// all its parents.
103-
this.toggleElementVisibility(invisibleEntry.parents);
107+
this.toggleElementVisibility(invisibleEntry.parentEl);
104108
}
105109
toggleVisibility(invisibleEntry.snippetEl);
106110
}

addons/html_builder/static/src/sidebar/invisible_elements_panel.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<ul t-if="entry.children.length > 0">
2424
<t t-foreach="entry.children" t-as="child" t-key="child_index">
2525
<li>
26-
<t t-call="html_builder.invisibleSnippetEntry" t-call-context="{'entry': child, menu}"/>
26+
<t t-call="html_builder.invisibleSnippetEntry" t-call-context="{'entry': child, toggleElementVisibility}"/>
2727
</li>
2828
</t>
2929
</ul>

0 commit comments

Comments
 (0)