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;
}
}
if (!$subMenuTitle && count($moduleMenus))
if (!$subMenuTitle && $currentAct && count($moduleMenus))
{
$subMenuTitle = array_first($moduleMenus)->title;
}
if (!$subMenuTitle)
{
$moduleInfo = \ModuleModel::getModuleInfoXml($module);
$subMenuTitle = $moduleInfo->title ?? 'Dashboard';
if ($currentAct)
{
$moduleInfo = \ModuleModel::getModuleInfoXml($module);
$subMenuTitle = $moduleInfo->title ?? 'Dashboard';
}
else
{
$subMenuTitle = 'Dashboard';
}
}
// get current menu's srl(=parentSrl)
@ -135,12 +142,14 @@ class Base extends \ModuleObject
$firstChild = current($parentMenu['list']);
$menu->list[$parentKey]['href'] = $firstChild['href'];
}
foreach ($parentMenu['list'] as $childMenu)
if ($currentAct)
{
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'];
}
}
}
}