Skip to content

Commit

Permalink
Merge pull request #768 from kilab-dev/open-tabs-from-url
Browse files Browse the repository at this point in the history
Open specific tab from hyperlink
  • Loading branch information
FreexD committed May 3, 2021
2 parents f061239 + 7806af2 commit 327bab2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/js/src/tab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Tab } from 'bootstrap';

export const EnableActivationTabsFromLocationHash = () => {
const locationHash = window.location.hash;

if (locationHash) {
const tabsList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tab"]'));
const matchedTabs = tabsList.filter(tab => tab.hash === locationHash);

matchedTabs.map(tab => {
new Tab(tab).show();
});
}
}
2 changes: 2 additions & 0 deletions src/js/tabler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ import './src/dropdown';
import './src/tooltip';
import './src/popover';
import './src/switch-icon';
import { EnableActivationTabsFromLocationHash } from './src/tab';
import './src/toast';

EnableActivationTabsFromLocationHash();

0 comments on commit 327bab2

Please sign in to comment.