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

Research - Navigation - AppBarContainer structured with routes children #255

Open
Dias999 opened this issue Oct 10, 2024 · 0 comments
Open

Comments

@Dias999
Copy link
Contributor

Dias999 commented Oct 10, 2024

Today the AppBarContainer is composed like this in the AppBarContainer:

<AppBar.Root key={location.pathname}>
  <AppBar.Drawer
    currentId={location.pathname}
    logo="/logo.svg"
    collapsible
    expandedWidth={120}
    {...drawerProps}
    items={drawerItems}
  />
  <AppBar.Main>
    <AppBar.Nav
      text={(user as any)?.username || ''}
      headerMenuOptions={(handleClose) => (
        <MenuItem onClick={() => onLogoutClick(handleClose)}>
          Sign Out
        </MenuItem>
      )}
      {...navbarProps}
    />
    <Container>{children}</Container>
  </AppBar.Main>
</AppBar.Root>

This causes the drawer to be remounted in every route change and this is probably why it's open/close state is lost.
Ideally we should use react-router-dom routes, children routes and Outlet to render the container in a separate hierarchy from the router content. This will prevent the container re-rendering, (probably) keep the drawer state and improve performance on changing routes.

Research how to structure the following components in the routes structure:
AppBar.Root
AppBar.Drawer
AppBar.Main
AppBar.Nav
Container

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant