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

[>=4.20.8] Missing active CSS class on Dashboard route #6701

Closed
Aerendir opened this issue Jan 11, 2025 · 2 comments · Fixed by #6702 or #6734
Closed

[>=4.20.8] Missing active CSS class on Dashboard route #6701

Aerendir opened this issue Jan 11, 2025 · 2 comments · Fixed by #6702 or #6734

Comments

@Aerendir
Copy link
Contributor

Aerendir commented Jan 11, 2025

Describe the bug
When accessing the Dashboard, the menù item is not highlighted as active anymore.

To Reproduce
Login in EasyAdmin: the Dashboard route is not highlighted.

(OPTIONAL) Additional context
Before 4.20.8, the li tag had the css class active: it visually highlights the current route. This is missed only on Dashboard.

The problem seems in \EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto::$selected: the property is not set to true anymore and this prevents the template menu.html.twig to recognize the route as the active one:

<li class="{{ menuItem.isMenuSection ? 'menu-header' : 'menu-item' }} {{ menuItem.hasSubItems ? 'has-submenu' }} {{ menuItem.isSelected ? 'active' }} {{ menuItem.isExpanded ? 'expanded' }}">

Digging deeper in the code, seems that this snippet caused the issue:

$request = $event->getRequest();
if (false === $request->attributes->has(EA::ROUTE_CREATED_BY_EASYADMIN)) {
return;
}

The route, infact, has the request attribute routeCreatedByEasyAdmin to false: this leads to the return and the MenuItemDto doesn't have property active set to true.

However, commenting the return, leads to an error, so this doesn't seem the right path to follow.

I'm not so versed in EasyAdmin to fix the issue and submit a PR: sorry 😔

@javiereguiluz
Copy link
Collaborator

Yes, this is exactly the cause of the error. I'm working on a new nice feature related to pretty URLs that will indirectly fix this too.

@Aerendir
Copy link
Contributor Author

@javiereguiluz , this issue is not fixed: I'm testing with 4.21.1 and the CSS class is still absent in the markup.

Screenshot 2025-01-14 alle 09 40 06

Maybe have I to update something else to make it work or the old configuration I have on 4.20.7 should be sufficient?

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