Manage scrolling on share modals
This commit is contained in:
parent
458f36f4a2
commit
a023cbf311
@ -10,11 +10,13 @@ export default function IconPathButton({
|
||||
path,
|
||||
prefetch,
|
||||
loaderDelay = 250,
|
||||
shouldScroll = true,
|
||||
}: {
|
||||
icon: JSX.Element
|
||||
path: string
|
||||
prefetch?: boolean
|
||||
loaderDelay?: number
|
||||
shouldScroll?: boolean
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
@ -43,7 +45,7 @@ export default function IconPathButton({
|
||||
<IconButton
|
||||
icon={icon}
|
||||
onClick={() => startTransition(() =>
|
||||
router.push(path))}
|
||||
router.push(path, { scroll: shouldScroll }))}
|
||||
isLoading={shouldShowLoader}
|
||||
className={cc(
|
||||
'active:translate-y-[1px]',
|
||||
|
||||
@ -28,7 +28,7 @@ export default function Modal({
|
||||
|
||||
useClickInsideOutside({
|
||||
htmlElements,
|
||||
onClickOutside: () => router.push(onClosePath ?? '/'),
|
||||
onClickOutside: () => router.push(onClosePath ?? '/', { scroll: false}),
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
@ -41,6 +41,7 @@ export default function PhotoDetailPage({
|
||||
tag={tag}
|
||||
priority
|
||||
prefetchShare
|
||||
shouldScrollOnShare={false}
|
||||
/>,
|
||||
]}
|
||||
/>
|
||||
|
||||
@ -12,11 +12,13 @@ export default function PhotoLarge({
|
||||
tag,
|
||||
priority,
|
||||
prefetchShare,
|
||||
shouldScrollOnShare,
|
||||
}: {
|
||||
photo: Photo
|
||||
tag?: string
|
||||
priority?: boolean
|
||||
prefetchShare?: boolean
|
||||
shouldScrollOnShare?: boolean
|
||||
}) {
|
||||
const tagsToShow = photo.tags.filter(t => t !== tag);
|
||||
|
||||
@ -101,6 +103,7 @@ export default function PhotoLarge({
|
||||
photo={photo}
|
||||
tag={tag}
|
||||
prefetch={prefetchShare}
|
||||
shouldScroll={shouldScrollOnShare}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -7,16 +7,19 @@ export default function SharePhotoButton({
|
||||
photo,
|
||||
tag,
|
||||
prefetch,
|
||||
shouldScroll,
|
||||
}: {
|
||||
photo: Photo
|
||||
tag?: string
|
||||
prefetch?: boolean
|
||||
shouldScroll?: boolean
|
||||
}) {
|
||||
return (
|
||||
<IconPathButton
|
||||
icon={<TbPhotoShare size={17} />}
|
||||
path={pathForPhotoShare(photo, tag)}
|
||||
prefetch={prefetch}
|
||||
shouldScroll={shouldScroll}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user