SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js

Home Page:https://adminjs.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: href with search filter on resource removes sidebar navigation active state for the page using it

BrunoDeye opened this issue · comments

commented

Contact Details

discord @bruno_15980

What happened?

When using href with a search query on the resource, the function isSelected from the useNavigationResources in the source code doenst works correctly. Leading to a misfunction of the Sidebar navigation, that doesnt mark as active the nav button when the resource page is opened. My solution was to create a custom 'SidebarResourceSection' modifying the isSelected function to this:

image

the source code:

image

the resource with the href modified:

image

the behavior before the modification:

image

the behavior after the modification:

image

Bug prevalence

Always

AdminJS dependencies version

indiferent

What browsers do you see the problem on?

No response

Relevant log output

No response

Relevant code that's giving you issues

const isSelected = (href, location): boolean => {
const regExp = new RegExp(`${href}($|/)`)
return !!location.pathname.match(regExp)
}