Skip to content

Commit 36d567e

Browse files
authored
Fix duplicate ID issue (#97)
Whoops...the old code also caused clicks of the separator to make the tab contents disappear. How embarrassing.
1 parent 9cb4cb8 commit 36d567e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

public/js/modules/explore.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -770,22 +770,22 @@ let renderTabs = function (container, texts, panels, renderCallbacks, transition
770770
for (let i = 0; i < texts.length; i++) {
771771
let tabContainer = document.createElement('span');
772772
tabContainer.classList.add('explore-tab');
773-
tabContainer.id = `tab-${texts[i].toLowerCase()}`;
773+
tabContainer.dataset.tabid = `tab-${texts[i].toLowerCase()}`;
774774
if (i === 0) {
775775
tabContainer.classList.add('active');
776776
}
777777
tabContainer.innerText = texts[i];
778778
renderSeparator(tabContainer);
779779
container.appendChild(tabContainer);
780-
tabs[tabContainer.id] = {
780+
tabs[tabContainer.dataset.tabid] = {
781781
tab: tabContainer,
782782
panel: panels[i],
783783
callback: renderCallbacks[i],
784784
transitionClass: transitionClasses[i]
785785
};
786786

787-
tabContainer.addEventListener('click', function (event) {
788-
switchToTab(event.target.id, tabs);
787+
tabContainer.addEventListener('click', function () {
788+
switchToTab(tabContainer.dataset.tabid, tabs);
789789
});
790790
}
791791
return tabs;

0 commit comments

Comments
 (0)