Skip to content

Commit

Permalink
[MWPW-136406] Tabs block enhancement: deep linking (#2652)
Browse files Browse the repository at this point in the history
* query param for focused tab

* addressed feedback
  • Loading branch information
robert-bogos authored Aug 5, 2024
1 parent 11664e1 commit 6a1f89b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/blocks/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ function configTabs(config, rootElem) {
const sel = rootElem.querySelector(id);
if (sel) sel.click();
}
const tabParam = new URLSearchParams(window.location.search).get('tab');
if (!tabParam) return;
const dashIndex = tabParam.lastIndexOf('-');
const [tabsId, tabIndex] = [tabParam.substring(0, dashIndex), tabParam.substring(dashIndex + 1)];
if (tabsId === config.id) rootElem.querySelector(`#tab-${config.id}-${tabIndex}`)?.click();

Check warning on line 75 in libs/blocks/tabs/tabs.js

View check run for this annotation

Codecov / codecov/patch

libs/blocks/tabs/tabs.js#L73-L75

Added lines #L73 - L75 were not covered by tests
}

function initTabs(elm, config, rootElem) {
Expand Down

0 comments on commit 6a1f89b

Please sign in to comment.