Skip to content

Commit

Permalink
Better way to retrieve the first tab ID if active tab is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosampaio authored and mage2pratik committed Jul 18, 2018
1 parent 9c7687a commit 1aec473
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions app/code/Magento/Backend/Block/Widget/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,16 @@ protected function _beforeToHtml()
{
$this->_tabs = $this->reorderTabs();

if ($this->_activeTab === null) {
/** @var TabInterface $tab */
foreach ($this->_tabs as $tab) {
$this->_activeTab = $tab->getId();
break;
}
}

if ($activeTab = $this->getRequest()->getParam('active_tab')) {
$this->setActiveTab($activeTab);
} elseif ($activeTabId = $this->_authSession->getActiveTabId()) {
$this->_setActiveTab($activeTabId);
}

if ($this->_activeTab === null && !empty($this->_tabs)) {
/** @var TabInterface $tab */
$this->_activeTab = (reset($this->_tabs))->getId();
}

$this->assign('tabs', $this->_tabs);
return parent::_beforeToHtml();
Expand All @@ -256,7 +253,7 @@ protected function _beforeToHtml()
/**
* @return array
*/
protected function reorderTabs()
private function reorderTabs()
{
$orderByIdentity = [];
$orderByPosition = [];
Expand Down

0 comments on commit 1aec473

Please sign in to comment.