Skip to content

Commit a0ec11b

Browse files
ENGCOM-6268: M2C-22619 Fix Tabs widget with Accordion #25515
2 parents 03d50d8 + d287cb8 commit a0ec11b

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

lib/web/mage/tabs.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,51 @@ define([
102102
* @private
103103
*/
104104
_processPanels: function () {
105-
this.contents = this.element.find(this.options.content);
105+
var isNotNested = this._isNotNested.bind(this);
106106

107-
this.collapsibles = this.element.find(this.options.collapsibleElement);
107+
this.contents = this.element
108+
.find(this.options.content)
109+
.filter(isNotNested);
110+
111+
this.collapsibles = this.element
112+
.find(this.options.collapsibleElement)
113+
.filter(isNotNested);
108114

109115
this.collapsibles
110116
.attr('role', 'presentation')
111117
.parent()
112118
.attr('role', 'tablist');
113119

114-
this.headers = this.element.find(this.options.header);
120+
this.headers = this.element
121+
.find(this.options.header)
122+
.filter(isNotNested);
115123

116124
if (this.headers.length === 0) {
117125
this.headers = this.collapsibles;
118126
}
119-
this.triggers = this.element.find(this.options.trigger);
127+
this.triggers = this.element
128+
.find(this.options.trigger)
129+
.filter(isNotNested);
120130

121131
if (this.triggers.length === 0) {
122132
this.triggers = this.headers;
123133
}
124134
this._callCollapsible();
125135
},
126136

137+
/**
138+
* Checks if element is not in nested container to keep the correct scope of collapsible
139+
* @param {Number} index
140+
* @param {HTMLElement} element
141+
* @private
142+
* @return {Boolean}
143+
*/
144+
_isNotNested: function (index, element) {
145+
var parentContent = $(element).parents(this.options.content);
146+
147+
return !parentContent.length || !this.element.find(parentContent).length;
148+
},
149+
127150
/**
128151
* Setting the disabled and active tabs and calling instantiation of collapsible
129152
* @private

0 commit comments

Comments
 (0)