diff --git a/src/plugins/panelTabs.js b/src/plugins/panelTabs.js index 8fd0e70..69ee1a7 100644 --- a/src/plugins/panelTabs.js +++ b/src/plugins/panelTabs.js @@ -73,6 +73,8 @@ export class PanelTabs extends Plugin { this.setupNavEvents(); + this.on('init', this.showActiveTab.bind(this)); + Bulma(this.root).data('panelTabs', this); this.trigger('init'); @@ -136,6 +138,25 @@ export class PanelTabs extends Plugin { } }); } + + /** + * This is called on init and will setup the panel tabs for the current active tab, if any + */ + showActiveTab() { + let activeNavFound = false; + + Bulma.each(this.navItems, (navItem) => { + if(navItem.classList.contains('is-active')) { + this.setActive(navItem.getAttribute('data-target')); + activeNavFound = true; + } + }); + + // If no nav item has is-active then use the first one + if(!activeNavFound) { + this.setActive(this.navItems[0].getAttribute('data-target')); + } + } } Bulma.registerPlugin('panelTabs', PanelTabs);