Fixes the scroll to Contact from the price cards
Removing ?pakket= from the URL replaced the click's navigation before the router scrolled to #contact, and told it not to scroll, so nothing happened. The clean-up now asks the router to scroll there, below the fixed header. The review carousel's placeholder is now the longest review itself, so it matches the carousel's height at every width and no longer shifts the target while the page scrolls past it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { lazy, Suspense, useEffect, useMemo, useState } from 'react';
|
||||
import { Box } from '@chakra-ui/react';
|
||||
import { Box, useMediaQuery } from '@chakra-ui/react';
|
||||
import { useNavigate } from '@tanstack/react-router';
|
||||
import { DEFERRED_LOAD_MARGIN } from '@/components/DeferredImage/DeferredImage';
|
||||
import ContactFormGate from '@/components/ContactForm/ContactFormGate';
|
||||
@@ -72,8 +72,14 @@ export default function ContactSection({
|
||||
}
|
||||
}
|
||||
|
||||
// Then remove ?pakket= from the address bar (no extra history entry, no
|
||||
// scroll) and continue keyboard and screen reader users here
|
||||
// Then remove ?pakket= from the address bar (no extra history entry) and
|
||||
// continue keyboard and screen reader users here. This navigation
|
||||
// replaces the "Boek" click's before the router has scrolled for it, so
|
||||
// it must ask the router to scroll to #contact itself.
|
||||
const [reducedMotion] = useMediaQuery(
|
||||
['(prefers-reduced-motion: reduce)'],
|
||||
{ ssr: false },
|
||||
);
|
||||
useEffect(() => {
|
||||
if (pakket === undefined) return;
|
||||
void navigate({
|
||||
@@ -82,9 +88,14 @@ export default function ContactSection({
|
||||
hash: 'contact',
|
||||
replace: true,
|
||||
resetScroll: false,
|
||||
hashScrollIntoView: false,
|
||||
hashScrollIntoView: {
|
||||
behavior: reducedMotion ? 'auto' : 'smooth',
|
||||
block: 'start',
|
||||
},
|
||||
});
|
||||
document.getElementById(TITLE_ID)?.focus({ preventScroll: true });
|
||||
// Only when a new ?pakket= arrives, not when the motion setting changes
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [pakket, navigate]);
|
||||
|
||||
const subject = mailSubject(chosenName);
|
||||
|
||||
Reference in New Issue
Block a user