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

Fix: Adjust Bug Causing Double-Selected <NavLink/> #10

Merged
merged 1 commit into from
May 10, 2024
Merged
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
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
Loading