Fix incorrect admin menu opening in Dashboard #2345

This commit is contained in:
Kijin Sung 2024-05-09 00:03:56 +09:00
parent 1dbf601bab
commit 3a91bc3038

View file

@ -112,14 +112,21 @@ class Base extends \ModuleObject
break; break;
} }
} }
if (!$subMenuTitle && count($moduleMenus)) if (!$subMenuTitle && $currentAct && count($moduleMenus))
{ {
$subMenuTitle = array_first($moduleMenus)->title; $subMenuTitle = array_first($moduleMenus)->title;
} }
if (!$subMenuTitle) if (!$subMenuTitle)
{ {
$moduleInfo = \ModuleModel::getModuleInfoXml($module); if ($currentAct)
$subMenuTitle = $moduleInfo->title ?? 'Dashboard'; {
$moduleInfo = \ModuleModel::getModuleInfoXml($module);
$subMenuTitle = $moduleInfo->title ?? 'Dashboard';
}
else
{
$subMenuTitle = 'Dashboard';
}
} }
// get current menu's srl(=parentSrl) // get current menu's srl(=parentSrl)
@ -135,12 +142,14 @@ class Base extends \ModuleObject
$firstChild = current($parentMenu['list']); $firstChild = current($parentMenu['list']);
$menu->list[$parentKey]['href'] = $firstChild['href']; $menu->list[$parentKey]['href'] = $firstChild['href'];
} }
if ($currentAct)
foreach ($parentMenu['list'] as $childMenu)
{ {
if ($subMenuTitle == $childMenu['text'] && $parentSrl == 0) foreach ($parentMenu['list'] as $childMenu)
{ {
$parentSrl = $childMenu['parent_srl']; if (preg_match('/\b' . preg_quote($currentAct, '/') . '$/', $childMenu['href']))
{
$parentSrl = $childMenu['parent_srl'];
}
} }
} }
} }