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

Reset/restore scroll when navigating through the app #3410

Merged
merged 1 commit into from
Oct 23, 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
11 changes: 11 additions & 0 deletions frontend/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const PasswordChangeSuccessLazyImport = createFileRoute(
// Create/Update Routes

const ResetCrossSigningRoute = ResetCrossSigningImport.update({
id: '/reset-cross-signing',
path: '/reset-cross-signing',
getParentRoute: () => rootRoute,
} as any).lazy(() =>
Expand All @@ -46,65 +47,75 @@ const AccountRoute = AccountImport.update({
} as any).lazy(() => import('./routes/_account.lazy').then((d) => d.Route))

const AccountIndexRoute = AccountIndexImport.update({
id: '/',
path: '/',
getParentRoute: () => AccountRoute,
} as any).lazy(() =>
import('./routes/_account.index.lazy').then((d) => d.Route),
)

const DevicesSplatRoute = DevicesSplatImport.update({
id: '/devices/$',
path: '/devices/$',
getParentRoute: () => rootRoute,
} as any)

const ClientsIdRoute = ClientsIdImport.update({
id: '/clients/$id',
path: '/clients/$id',
getParentRoute: () => rootRoute,
} as any).lazy(() => import('./routes/clients.$id.lazy').then((d) => d.Route))

const PasswordRecoveryIndexRoute = PasswordRecoveryIndexImport.update({
id: '/password/recovery/',
path: '/password/recovery/',
getParentRoute: () => rootRoute,
} as any).lazy(() =>
import('./routes/password.recovery.index.lazy').then((d) => d.Route),
)

const PasswordChangeIndexRoute = PasswordChangeIndexImport.update({
id: '/password/change/',
path: '/password/change/',
getParentRoute: () => rootRoute,
} as any).lazy(() =>
import('./routes/password.change.index.lazy').then((d) => d.Route),
)

const AccountSessionsIndexRoute = AccountSessionsIndexImport.update({
id: '/sessions/',
path: '/sessions/',
getParentRoute: () => AccountRoute,
} as any).lazy(() =>
import('./routes/_account.sessions.index.lazy').then((d) => d.Route),
)

const PasswordChangeSuccessLazyRoute = PasswordChangeSuccessLazyImport.update({
id: '/password/change/success',
path: '/password/change/success',
getParentRoute: () => rootRoute,
} as any).lazy(() =>
import('./routes/password.change.success.lazy').then((d) => d.Route),
)

const EmailsIdVerifyRoute = EmailsIdVerifyImport.update({
id: '/emails/$id/verify',
path: '/emails/$id/verify',
getParentRoute: () => rootRoute,
} as any).lazy(() =>
import('./routes/emails.$id.verify.lazy').then((d) => d.Route),
)

const AccountSessionsBrowsersRoute = AccountSessionsBrowsersImport.update({
id: '/sessions/browsers',
path: '/sessions/browsers',
getParentRoute: () => AccountRoute,
} as any).lazy(() =>
import('./routes/_account.sessions.browsers.lazy').then((d) => d.Route),
)

const AccountSessionsIdRoute = AccountSessionsIdImport.update({
id: '/sessions/$id',
path: '/sessions/$id',
getParentRoute: () => AccountRoute,
} as any).lazy(() =>
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.

import { Outlet, createRootRouteWithContext } from "@tanstack/react-router";
import {
Outlet,
ScrollRestoration,
createRootRouteWithContext,
} from "@tanstack/react-router";
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
import type { Client } from "urql";

Expand All @@ -16,6 +20,7 @@ export const Route = createRootRouteWithContext<{
}>()({
component: () => (
<>
<ScrollRestoration />
<Outlet />
{import.meta.env.DEV && <TanStackRouterDevtools />}
</>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/routes/_account.sessions.browsers.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function BrowserSessions(): React.ReactElement {
disabled={!forwardPage}
to="/sessions/browsers"
search={forwardPage || pagination}
resetScroll
>
{t("common.previous")}
</ButtonLink>
Expand All @@ -106,6 +107,7 @@ function BrowserSessions(): React.ReactElement {
disabled={!backwardPage}
to="/sessions/browsers"
search={backwardPage || pagination}
resetScroll
>
{t("common.next")}
</ButtonLink>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/routes/_account.sessions.index.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function Sessions(): React.ReactElement {
disabled={!forwardPage}
to="/sessions"
search={{ inactive, ...(forwardPage || pagination) }}
resetScroll
>
{t("common.previous")}
</ButtonLink>
Expand All @@ -125,6 +126,7 @@ function Sessions(): React.ReactElement {
disabled={!backwardPage}
to="/sessions"
search={{ inactive, ...(backwardPage || pagination) }}
resetScroll
>
{t("common.next")}
</ButtonLink>
Expand Down
Loading