mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 09:41:04 +01:00
Fix tasks page scroll reset
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
59cda0bc91
commit
d29a6c895d
2 files changed
+40
No files matched your search
@@ -41,6 +41,37 @@ describe("navigation-scroll", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("resets scroll when navigating into the top-level issues page", () => {
|
||||
expect(
|
||||
shouldResetScrollOnNavigation({
|
||||
previousPathname: "/issues/PAP-1389",
|
||||
pathname: "/issues",
|
||||
navigationType: "PUSH",
|
||||
state: null,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldResetScrollOnNavigation({
|
||||
previousPathname: "/PAP/issues/PAP-1389",
|
||||
pathname: "/PAP/issues",
|
||||
navigationType: "REPLACE",
|
||||
state: null,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("does not reset issues page scroll on browser history restoration", () => {
|
||||
expect(
|
||||
shouldResetScrollOnNavigation({
|
||||
previousPathname: "/issues/PAP-1389",
|
||||
pathname: "/issues",
|
||||
navigationType: "POP",
|
||||
state: null,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("resets scroll when navigating directly between issue detail routes", () => {
|
||||
expect(
|
||||
shouldResetScrollOnNavigation({
|
||||
|
||||
@@ -14,6 +14,7 @@ export function shouldResetScrollOnNavigation(params: {
|
||||
if (previousPathname === null) return false;
|
||||
if (previousPathname === pathname) return false;
|
||||
if (navigationType === "POP") return false;
|
||||
if (isIssueIndexPath(pathname)) return true;
|
||||
if (isIssueDetailPathChange(previousPathname, pathname)) return true;
|
||||
return hasSidebarScrollResetState(state);
|
||||
}
|
||||
@@ -75,6 +76,14 @@ function isIssueDetailPathChange(previousPathname: string, pathname: string): bo
|
||||
return previousIssueRef !== null && nextIssueRef !== null && previousIssueRef !== nextIssueRef;
|
||||
}
|
||||
|
||||
function isIssueIndexPath(pathname: string): boolean {
|
||||
const segments = pathname.split("/").filter(Boolean);
|
||||
return (
|
||||
(segments.length === 1 && segments[0] === "issues")
|
||||
|| (segments.length === 2 && segments[1] === "issues")
|
||||
);
|
||||
}
|
||||
|
||||
function readIssueDetailPathRef(pathname: string): string | null {
|
||||
const segments = pathname.split("/").filter(Boolean);
|
||||
if (segments.length === 2 && segments[0] === "issues") {
|
||||
|
||||
Reference in new issue
Block a user