From 1aec473133d1ec2558914aafacde91e6f29ace3c Mon Sep 17 00:00:00 2001 From: Tiago Sampaio Date: Fri, 22 Jun 2018 15:45:25 -0300 Subject: [PATCH] Better way to retrieve the first tab ID if active tab is empty. --- app/code/Magento/Backend/Block/Widget/Tabs.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Backend/Block/Widget/Tabs.php b/app/code/Magento/Backend/Block/Widget/Tabs.php index 88508d52151b9..b577d80bb5db6 100644 --- a/app/code/Magento/Backend/Block/Widget/Tabs.php +++ b/app/code/Magento/Backend/Block/Widget/Tabs.php @@ -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(); @@ -256,7 +253,7 @@ protected function _beforeToHtml() /** * @return array */ - protected function reorderTabs() + private function reorderTabs() { $orderByIdentity = []; $orderByPosition = [];