yii2-bootstrap4
yii2-bootstrap4 copied to clipboard
First tab in `Tabs` is active even if URL activates another
Tabs::widget([
'renderTabContent' => false,
'items' => [
[
'label' => 'Tab 1',
'url' => ['/default/index'],
],
[
'label' => 'Tab 2',
'url' => ['/default/page2'],
],
]
]);
The Tabs widget uses the Nav widget to build the tabs which causes a conflict with activating.
If the route matches the url for Tab 2 Nav will activate it but Tab 1 has already been activated by Tabs.
I was thinking of either adding an option to turn off Tabs::activateFirstVisibleTab() or if the items have urls then defer activation to Nav.
| Q | A |
|---|---|
| Yii vesion | 2.0.35 |
| Yii BS4 version | 2.0.8 |
@samdark I can do a PR for this but wondering which way is preferable?
An option to disable the Tabs::activateFirstVisibleTab method or if the items use url's then let Nav do the activation?
In my opinion there should be an active option in items array, if there is none (in none of the items), the first will be activated, otherwhise the one activated.
@simialbi This is the way it works currently but if you try to activate a tab using the route you get multiple tabs activated.
If there's explicit active we should not check for route, I think.