Manage scrolling on share modals

This commit is contained in:
Sam Becker 2023-09-21 18:20:56 -05:00
parent 458f36f4a2
commit a023cbf311
5 changed files with 11 additions and 2 deletions

View File

@ -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]',

View File

@ -28,7 +28,7 @@ export default function Modal({
useClickInsideOutside({
htmlElements,
onClickOutside: () => router.push(onClosePath ?? '/'),
onClickOutside: () => router.push(onClosePath ?? '/', { scroll: false}),
});
return (

View File

@ -41,6 +41,7 @@ export default function PhotoDetailPage({
tag={tag}
priority
prefetchShare
shouldScrollOnShare={false}
/>,
]}
/>

View File

@ -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>

View File

@ -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}
/>
);
}