Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New logic of Menu item matcher displays as selected all same crud controller in Sub Menus #6521

Open
AmazingBeu opened this issue Nov 7, 2024 · 0 comments

Comments

@AmazingBeu
Copy link

Describe the bug

with the new logic of Menu item matcher introduced in ee2c0ae, all SubMenu Items with the same Crud are selected, instead of the specific selected:
image

Comment out this function fix the behavior:

$menuItemController = $menuItemQueryParameters[EA::CRUD_CONTROLLER_FQCN] ?? null;
$currentPageController = $currentPageQueryParameters[EA::CRUD_CONTROLLER_FQCN] ?? null;
$actionsLinkedInTheMenuForThisEntity = $controllersAndActionsLinkedInTheMenu[$currentPageController] ?? [];
$menuOnlyLinksToIndexActionOfThisEntity = $actionsLinkedInTheMenuForThisEntity === [Crud::PAGE_INDEX];
if ($menuItemController === $currentPageController && $menuOnlyLinksToIndexActionOfThisEntity) {
$menuItemDto->setSelected(true);
break;
}

a possible workaround is to add a second MenuItem of the same Crud in the same SubMenu like this:

yield MenuItem::linkToCrud('', '', Team::class)->setHtmlAttribute("hidden", "1")

It break my usage of parent -> child entities:
image

To Reproduce

class DashboardController extends AbstractDashboardController
{
    public function configureMenuItems(): iterable
    {
        yield MenuItem::subMenu('subMenu 1')->setSubItems([
            MenuItem::linkToCrud('subItem 1', '', User::class)->setQueryParameter("ParentId", 1)          
        ]);
        yield MenuItem::subMenu('subMenu 2')->setSubItems([
            MenuItem::linkToCrud('subItem 2', '', User::class)->setQueryParameter("ParentId", 2)          
        ]);
    }
}

then click on one of the SubItem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant