Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ const SidebarCollapseItem = ({ icon, label, nestedLinks }) => {
const [open, setOpen] = useState(false)
const { open: sidebarOpen } = useSidebar()

const isAnyChildActive = nestedLinks.some(nested =>
nested.link ? pathname.includes(nested.link.toLowerCase()) : false
)
const isAnyChildActive = nestedLinks.some(nested => {
if (!nested.link) return false
try {
return pathname.toLowerCase().startsWith(new URL(nested.link).pathname.toLowerCase())
} catch {
return pathname.toLowerCase().startsWith(nested.link.toLowerCase())
}
})

return (
<Collapsible
Expand Down
13 changes: 11 additions & 2 deletions src/nextGenComponents/shared/Sidebar/SidebarItem/SidebarItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
import { useEffect, useRef } from 'react'
import { useEffect, useMemo, useRef } from 'react'
import PropTypes from 'prop-types'
import { Link, useMatch } from 'react-router-dom'
import { SidebarMenuButton, SidebarMenuItem, useSidebar } from 'igz-controls/nextGenComponents'
Expand All @@ -34,7 +34,16 @@ const SidebarItem = ({
const ref = useRef(null)
const { open: sidebarOpen } = useSidebar()

const match = useMatch(link ? `${link}/*` : null)
const linkPath = useMemo(() => {
if (!link) return null
try {
return new URL(link).pathname
} catch {
return link
}
}, [link])

const match = useMatch(linkPath ? `${linkPath}/*` : null)
const isActive = Boolean(match)

useEffect(() => {
Expand Down
Loading