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 router to accept nested routes #136

Open
rluders opened this issue Nov 13, 2022 · 5 comments
Open

Fix router to accept nested routes #136

rluders opened this issue Nov 13, 2022 · 5 comments
Assignees
Labels
bug 🐛 Something isn't working

Comments

@rluders
Copy link
Contributor

rluders commented Nov 13, 2022

Description

The current route structure doesn't support nested routes, which causes some undesired full-page reloads while navigating between pages.

Steps to reproduce

Steps to reproduce the behavior:

  1. Clone the repo and run the project
  2. Login with any account
  3. Navigate between the pages
  4. See that it refreshes the whole page every time

Expected behavior

It should only load the content part of the page.

Screenshots

Screencast.from.11-13-2022.09.26.11.AM.webm

Desktop (please complete the following information):

N/A

Smartphone (please complete the following information):

N/A

Additional context

N/A

@rluders rluders added the bug 🐛 Something isn't working label Nov 13, 2022
@rluders rluders linked a pull request Nov 13, 2022 that will close this issue
@rluders rluders removed a link to a pull request Nov 13, 2022
@rluders
Copy link
Contributor Author

rluders commented Nov 17, 2022

It is almost 100% done. I'm not sure why it isn't working for the sidebar links. I'll double check it later.

@marianysilva
Copy link
Collaborator

Live code video

I tried to reproduce this page reload issue by adding a simple HTML component in the Sidebar component:

      <nav>
        <ul>
          {mainMenuItems.map(({ label, route, icon }: MenuListItemProps) => (
            <li key={route}>
              <NavLink to={route}>{label}</NavLink>
            </li>
          ))}
        </ul>
      </nav>

And I saw that it didn't happen.

I noticed that in <FlowbiteSidebar.Item /> of settingsMenuItems we are using the prop as={NavLink}, but in <FlowbiteSidebar.Item /> of mainMenuItems we didn't declare this, I don't know if it was on purpose. When I try to use the prop as={NavLink} the sidebar navigation stops working.

I believe this bug will have to be opened in the React Flowbite library, I don't know if it is related to an open issue.

@rluders
Copy link
Contributor Author

rluders commented Dec 22, 2022

@marianysilva So, I think that we have two things happening here:

  • When you use as={NavLink}, I think that you need to change href= with to=.
  • There was an PR created to improve how links are handled inside the navbar. But the change was dropped, maybe we could think about it, and consider some approach proposed there to improve the usage of as= or if we should use children for linking instead.

And last but not least, great job figuring out what was happening, I was utterly lost on this one.

@rluders rluders closed this as completed Mar 22, 2023
@rluders rluders reopened this Mar 22, 2023
@rluders
Copy link
Contributor Author

rluders commented Mar 22, 2023

Only when we are navigating between pages using the sidebar menu.

@marianysilva
Copy link
Collaborator

@marianysilva So, I think that we have two things happening here:

  • When you use as={NavLink}, I think that you need to change href= with to=.
  • There was an PR created to improve how links are handled inside the navbar. But the change was dropped, maybe we could think about it, and consider some approach proposed there to improve the usage of as= or if we should use children for linking instead.

And last but not least, great job figuring out what was happening, I was utterly lost on this one.

flowbite-reac PR merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
Status: Future
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants