Skip to content

Commit 43e37cf

Browse files
committed
fix(tabs): ensure syncPanels runs after md-tabs first render
1 parent a25184c commit 43e37cf

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/scripts/site.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ const initTabs = () => {
4242
};
4343

4444
tabs.addEventListener('change', syncPanels);
45-
syncPanels();
45+
46+
// md-tabs is a Lit component; wait for its first render before syncing so
47+
// that activeTabIndex reflects the `active` attribute on the first tab.
48+
const updateComplete = (tabs as unknown as { updateComplete?: Promise<boolean> }).updateComplete;
49+
(updateComplete ?? Promise.resolve()).then(syncPanels);
4650
});
4751
};
4852

0 commit comments

Comments
 (0)