Skip to content

Commit 1aec473

Browse files
tiagosampaiomage2pratik
authored andcommitted
Better way to retrieve the first tab ID if active tab is empty.
1 parent 9c7687a commit 1aec473

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
@@ -234,19 +234,16 @@ protected function _beforeToHtml()
234234
{
235235
$this->_tabs = $this->reorderTabs();
236236

237-
if ($this->_activeTab === null) {
238-
/** @var TabInterface $tab */
239-
foreach ($this->_tabs as $tab) {
240-
$this->_activeTab = $tab->getId();
241-
break;
242-
}
243-
}
244-
245237
if ($activeTab = $this->getRequest()->getParam('active_tab')) {
246238
$this->setActiveTab($activeTab);
247239
} elseif ($activeTabId = $this->_authSession->getActiveTabId()) {
248240
$this->_setActiveTab($activeTabId);
249241
}
242+
243+
if ($this->_activeTab === null && !empty($this->_tabs)) {
244+
/** @var TabInterface $tab */
245+
$this->_activeTab = (reset($this->_tabs))->getId();
246+
}
250247

251248
$this->assign('tabs', $this->_tabs);
252249
return parent::_beforeToHtml();
@@ -256,7 +253,7 @@ protected function _beforeToHtml()
256253
/**
257254
* @return array
258255
*/
259-
protected function reorderTabs()
256+
private function reorderTabs()
260257
{
261258
$orderByIdentity = [];
262259
$orderByPosition = [];

0 commit comments

Comments
 (0)