Skip to content

Commit 6dccd48

Browse files
committed
IBX-11191: Added support multiple section groups with the same data-id in anchor navigation
1 parent 8f12f43 commit 6dccd48

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/bundle/Resources/public/js/scripts/admin.anchor.navigation.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,21 @@
136136
const attachMenuTabShowEvents = () => {
137137
doc.querySelectorAll('.ibexa-anchor-navigation .ibexa-tabs__tab:not(.ibexa-tabs__tab--more)').forEach((tabLink) => {
138138
tabLink.addEventListener('shown.bs.tab', (event) => {
139-
const { target, relatedTarget } = event;
140-
const prevHashId = getTabHash(relatedTarget);
141-
const currHashId = getTabHash(target);
142-
const prevMainContentTab = doc.querySelector(`[data-id="${prevHashId}"]`);
143-
const currMainContentTab = doc.querySelector(`[data-id="${currHashId}"]`);
144-
145-
prevMainContentTab?.classList.toggle('ibexa-anchor-navigation__section-group--active', false);
146-
currMainContentTab?.classList.toggle('ibexa-anchor-navigation__section-group--active', true);
147-
148-
initFitSection();
139+
onAnchorTabShow(event);
149140
});
150141
});
151142
};
143+
const onAnchorTabShow = (event) => {
144+
const { target, relatedTarget } = event;
145+
const prevHashId = getTabHash(relatedTarget);
146+
const currHashId = getTabHash(target);
147+
const prevMainContentTabs = doc.querySelectorAll(`[data-id="${prevHashId}"]`);
148+
const currMainContentTabs = doc.querySelectorAll(`[data-id="${currHashId}"]`);
149+
150+
prevMainContentTabs?.forEach((tab) => tab.classList.toggle('ibexa-anchor-navigation__section-group--active', false));
151+
currMainContentTabs?.forEach((tab) => tab.classList.toggle('ibexa-anchor-navigation__section-group--active', true));
152+
initFitSection();
153+
};
152154
const attachMenuSectionsEvents = () => {
153155
const items = doc.querySelectorAll('.ibexa-anchor-navigation-menu .ibexa-anchor-navigation-menu__sections-item-btn');
154156

0 commit comments

Comments
 (0)