Skip to content

Commit 3252237

Browse files
committed
Better way to retrieve the first tab ID if active tab is empty.
1 parent 5f2cf41 commit 3252237

File tree

1 file changed

+6
-9
lines changed
  • app/code/Magento/Backend/Block/Widget

1 file changed

+6
-9
lines changed

app/code/Magento/Backend/Block/Widget/Tabs.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,19 +237,16 @@ protected function _beforeToHtml()
237237
{
238238
$this->_tabs = $this->reorderTabs();
239239

240-
if ($this->_activeTab === null) {
241-
/** @var TabInterface $tab */
242-
foreach ($this->_tabs as $tab) {
243-
$this->_activeTab = $tab->getId();
244-
break;
245-
}
246-
}
247-
248240
if ($activeTab = $this->getRequest()->getParam('active_tab')) {
249241
$this->setActiveTab($activeTab);
250242
} elseif ($activeTabId = $this->_authSession->getActiveTabId()) {
251243
$this->_setActiveTab($activeTabId);
252244
}
245+
246+
if ($this->_activeTab === null && !empty($this->_tabs)) {
247+
/** @var TabInterface $tab */
248+
$this->_activeTab = (reset($this->_tabs))->getId();
249+
}
253250

254251
$this->assign('tabs', $this->_tabs);
255252
return parent::_beforeToHtml();
@@ -259,7 +256,7 @@ protected function _beforeToHtml()
259256
/**
260257
* @return array
261258
*/
262-
protected function reorderTabs()
259+
private function reorderTabs()
263260
{
264261
$orderByIdentity = [];
265262
$orderByPosition = [];

0 commit comments

Comments
 (0)