Skip to content

Commit

Permalink
Merge pull request #10 from selsa-inube/cmarin/1581/adjust-double-sel…
Browse files Browse the repository at this point in the history
…ected-behavior

Fix: Adjust Bug Causing Double-Selected <NavLink/>
  • Loading branch information
cmarin001 committed May 10, 2024
2 parents bd601c9 + 16d7917 commit 7d3733f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/Nav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const Links = (props: INavLink) => {
const { section } = props;

const location = useLocation();
const currentUrl = location.pathname;

const LinkElements = section.map((sectionObject) => (
<NavLink
Expand All @@ -37,7 +36,7 @@ const Links = (props: INavLink) => {
label={sectionObject.label}
icon={sectionObject.icon}
path={sectionObject.path}
selected={currentUrl.startsWith(sectionObject.path)}
selected={location.pathname === sectionObject.path}
/>
));
return <>{LinkElements} </>;
Expand Down
24 changes: 12 additions & 12 deletions src/Nav/stories/Nav.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ Default.args = {
administrate: {
name: "Administrate",
links: {
privileges: {
id: "privileges",
label: "Privileges",
text: {
id: "text",
label: "Text",
icon: <MdKey />,
path: "/privileges",
path: "/components/text",
},
accounting: {
id: "accounting",
label: "Accounting",
textfield: {
id: "textfield",
label: "Textfield",
icon: <MdMeetingRoom />,
path: "/accounting",
path: "/components/textfield",
},
contacts: {
id: "contacts",
label: "Contacts",
textarea: {
id: "textarea",
label: "Textarea",
icon: <MdPhone />,
path: "/contacts",
path: "/components/textarea",
},
crm: {
id: "crm",
Expand Down

0 comments on commit 7d3733f

Please sign in to comment.