fix: scroll position
This commit is contained in:
parent
b4e5a05ae6
commit
349abc2071
|
|
@ -34,12 +34,7 @@ export const usePageContext = () => {
|
||||||
return context;
|
return context;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PageProvider = ({
|
export const PageProvider = ({ navItems, currentPath, rightSlot, children }: PageProviderProps) => {
|
||||||
navItems,
|
|
||||||
currentPath,
|
|
||||||
rightSlot,
|
|
||||||
children,
|
|
||||||
}: PageProviderProps) => {
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [modalContent, setModalContent] = useState<ReactNode | null>(null);
|
const [modalContent, setModalContent] = useState<ReactNode | null>(null);
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
|
@ -90,7 +85,7 @@ export const PageProvider = ({
|
||||||
if (!modalElement) return;
|
if (!modalElement) return;
|
||||||
|
|
||||||
const focusableElements = modalElement.querySelectorAll(
|
const focusableElements = modalElement.querySelectorAll(
|
||||||
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (focusableElements.length === 0) return;
|
if (focusableElements.length === 0) return;
|
||||||
|
|
@ -113,7 +108,9 @@ export const PageProvider = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
const closeButton = document.querySelector('[data-modal-overlay] button[aria-label="Close fullscreen view"]') as HTMLElement;
|
const closeButton = document.querySelector(
|
||||||
|
'[data-modal-overlay] button[aria-label="Close fullscreen view"]',
|
||||||
|
) as HTMLElement;
|
||||||
if (closeButton) {
|
if (closeButton) {
|
||||||
closeButton.focus();
|
closeButton.focus();
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +121,7 @@ export const PageProvider = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContext.Provider value={contextValue}>
|
<PageContext.Provider value={contextValue}>
|
||||||
<div className={isOpen ? 'hidden' : ''} aria-hidden={isOpen}>
|
<div aria-hidden={isOpen}>
|
||||||
<AnimatedBackground />
|
<AnimatedBackground />
|
||||||
<SubsectionNav items={navItems} currentPath={currentPath} rightSlot={rightSlot} />
|
<SubsectionNav items={navItems} currentPath={currentPath} rightSlot={rightSlot} />
|
||||||
<div className="relative z-10">{children}</div>
|
<div className="relative z-10">{children}</div>
|
||||||
|
|
@ -156,12 +153,7 @@ export const PageProvider = ({
|
||||||
className="w-9 h-9 sm:w-10 sm:h-10 rounded-full bg-white/10 hover:bg-white/20 text-white flex items-center justify-center transition-colors focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-black/90"
|
className="w-9 h-9 sm:w-10 sm:h-10 rounded-full bg-white/10 hover:bg-white/20 text-white flex items-center justify-center transition-colors focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-black/90"
|
||||||
aria-label="Close fullscreen view"
|
aria-label="Close fullscreen view"
|
||||||
>
|
>
|
||||||
<svg
|
<svg className="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
className="w-6 h-6"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
<path
|
||||||
strokeLinecap="round"
|
strokeLinecap="round"
|
||||||
strokeLinejoin="round"
|
strokeLinejoin="round"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue