diff --git a/src/components/CookieConsentBanner.tsx b/src/components/CookieConsentBanner.tsx index afe3c9f7..ca7e5d5d 100644 --- a/src/components/CookieConsentBanner.tsx +++ b/src/components/CookieConsentBanner.tsx @@ -3,12 +3,15 @@ import { ThemeButton } from './ThemeButton'; import { Check, X } from '@phosphor-icons/react'; import { useCookieContext } from '@/context/CookieContext'; -import { useEffect, useState } from 'react'; +import { useEffect, useState, useRef } from 'react'; const CookieConsentBanner = () => { const { shouldShowBanner, setShouldAllowCookies, setShouldShowBanner } = useCookieContext(); + const bannerRef = useRef(null); + const inputRef = useRef(null); + const [isClientSide, setIsClientSide] = useState(false); useEffect(() => { @@ -21,10 +24,24 @@ const CookieConsentBanner = () => { setShouldShowBanner(false); }; + useEffect(() => { + // Focus on the banner when it becomes visible + if (shouldShowBanner && bannerRef.current) { + // Use setTimeout to ensure focus is applied after DOM updates + setTimeout(() => { + bannerRef.current?.focus(); + }, 0); + } + }, [shouldShowBanner]); // Trigger focus when shouldShowBanner changes + if (!isClientSide) return null; return (
{ }`} >
-
Can we store cookies to your browser?
+
- This provides you a nice experience preserving your filtering, your - position on the map and your property saved list. +

+ This provides you a nice experience preserving your filtering, your + position on the map and your property saved list. +

} @@ -49,6 +71,7 @@ const CookieConsentBanner = () => { /> } diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 22955d3a..fcc85525 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -2,6 +2,7 @@ import { useCookieContext } from '@/context/CookieContext'; import CookieConsentBanner from './CookieConsentBanner'; +import { ThemeButton } from './ThemeButton'; import Link from 'next/link'; const Footer = () => { @@ -25,16 +26,15 @@ const Footer = () => { -
  • - - Cookie Settings - - + + +
  • +