Skip to content

Commit 91c8c77

Browse files
authored
docs: fix code snippet tabs (#2732)
1 parent b747688 commit 91c8c77

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

docs/components/components.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@
1616
---
1717

1818
<script type="module">
19-
const LS_KEY = 'html-lit-react-snippets-index';
19+
const CLASS_KEY = 'html-lit-react-snippets';
20+
const LS_KEY = `${CLASS_KEY}-index`;
2021
document.addEventListener('expand', async function(event) {
2122
const PfTabs = await customElements.whenDefined('pf-tabs');
2223
if (PfTabs.isExpandEvent(event)) {
23-
const tabs = event.target.closest('pf-tabs');
24-
await tabs.updateComplete;
25-
debugger;
26-
localStorage.setItem(LS_KEY, tabs.activeIndex);
27-
update();
24+
const tabs = event.tab.closest('pf-tabs');
25+
if (tabs.classList.contains(CLASS_KEY)) {
26+
await tabs.updateComplete;
27+
localStorage.setItem(LS_KEY, tabs.activeIndex);
28+
update();
29+
}
2830
}
2931
});
3032
async function update() {
31-
for (const tabs of document.querySelectorAll('pf-tabs.html-lit-react-snippets')) {
33+
for (const tabs of document.querySelectorAll(`pf-tabs.${CLASS_KEY}`)) {
3234
await tabs.updateComplete;
3335
tabs.activeIndex = parseInt(localStorage.getItem(LS_KEY) ?? '0');
3436
}

0 commit comments

Comments
 (0)