Skip to content

Commit de1ad63

Browse files
committed
fix: scroll up in parallel routes
1 parent a1d68b5 commit de1ad63

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/app/books/components/book-card.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Image from 'next/image'
33
import Link from 'next/link'
44

55
import { BookCardForm } from '@/app/books/components/book-card-form'
6+
import { ScrollUp } from '@/components/scroll-up'
67
import { BookResponse } from '@/core/book/dto/responses/book.response'
78
import { UserResponse } from '@/core/user/dto/responses/user.response'
89

@@ -32,6 +33,7 @@ export function BookCard(properties: BookCardProperties) {
3233

3334
return (
3435
<>
36+
<ScrollUp />
3537
<Card
3638
as={Link}
3739
className={`group max-w-[320px] space-y-4 border-t-4 p-4 ${cardColor}`}
@@ -40,7 +42,6 @@ export function BookCard(properties: BookCardProperties) {
4042
prefetch
4143
radius="none"
4244
role="gridcell"
43-
scroll={false}
4445
>
4546
<div className="relative">
4647
<Image

src/components/scroll-up.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use client'
2+
3+
import { useEffect } from 'react'
4+
5+
export function ScrollUp() {
6+
useEffect(() => window.document.scrollingElement?.scrollTo(0, 0), [])
7+
8+
return null
9+
}

0 commit comments

Comments
 (0)