Diff comments:
> diff --git a/frontend/src/components/MainLayout/MainLayout.tsx
> b/frontend/src/components/MainLayout/MainLayout.tsx
> index 9be3fca..3fe61c0 100644
> --- a/frontend/src/components/MainLayout/MainLayout.tsx
> +++ b/frontend/src/components/MainLayout/MainLayout.tsx
> @@ -19,21 +18,39 @@ export const sidebarLabels: Record<"removeRegions" |
> "createToken", string> = {
> createToken: "Generate tokens",
> };
>
> -type AsideProps = PropsWithChildren<Pick<ReturnType<typeof useAppContext>,
> "sidebar" | "setSidebar">>;
> -const Aside = ({ children, sidebar, setSidebar, ...props }: AsideProps) => {
> +const Aside = () => {
> + const { pathname } = useLocation();
> + const previousPathname = usePrevious(pathname);
> + const { sidebar, setSidebar } = useAppContext();
> +
> + // close any open panels on route change
> + useEffect(() => {
> + if (pathname !== previousPathname) {
> + setSidebar(null);
> + }
> + }, [pathname, previousPathname, setSidebar]);
> +
> useOnEscapePressed(() => {
> setSidebar(null);
> });
> +
> return (
> <aside
> aria-hidden={!sidebar}
> + aria-label={sidebar ? sidebarLabels[sidebar] : undefined}
> className={classNames("l-aside is-maas-site-manager
> u-padding-top--medium", { "is-collapsed": !sidebar })}
> id="aside-panel"
> role="dialog"
> - {...props}
> >
> <Row>
> - <Col size={12}>{children}</Col>
> + <Col size={12}>
> + {/* use context based on the route? */}
> + {!!sidebar && sidebar === "createToken" ? (
Good catch, it's a leftover from previous implementations. Will update.
> + <TokensCreate />
> + ) : !!sidebar && sidebar === "removeRegions" ? (
> + <RemoveRegions />
> + ) : null}
> + </Col>
> </Row>
> </aside>
> );
--
https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442736
Your team MAAS Committers is subscribed to branch
~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549.
--
Mailing list: https://launchpad.net/~sts-sponsors
Post to : sts-sponsors@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sts-sponsors
More help : https://help.launchpad.net/ListHelp