fix: scroll position
This commit is contained in:
parent
b4e5a05ae6
commit
349abc2071
|
|
@ -34,12 +34,7 @@ export const usePageContext = () => {
|
|||
return context;
|
||||
};
|
||||
|
||||
export const PageProvider = ({
|
||||
navItems,
|
||||
currentPath,
|
||||
rightSlot,
|
||||
children,
|
||||
}: PageProviderProps) => {
|
||||
export const PageProvider = ({ navItems, currentPath, rightSlot, children }: PageProviderProps) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [modalContent, setModalContent] = useState<ReactNode | null>(null);
|
||||
const pathname = usePathname();
|
||||
|
|
@ -90,7 +85,7 @@ export const PageProvider = ({
|
|||
if (!modalElement) return;
|
||||
|
||||
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;
|
||||
|
|
@ -113,7 +108,9 @@ export const PageProvider = ({
|
|||
|
||||
useEffect(() => {
|
||||
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) {
|
||||
closeButton.focus();
|
||||
}
|
||||
|
|
@ -124,7 +121,7 @@ export const PageProvider = ({
|
|||
|
||||
return (
|
||||
<PageContext.Provider value={contextValue}>
|
||||
<div className={isOpen ? 'hidden' : ''} aria-hidden={isOpen}>
|
||||
<div aria-hidden={isOpen}>
|
||||
<AnimatedBackground />
|
||||
<SubsectionNav items={navItems} currentPath={currentPath} rightSlot={rightSlot} />
|
||||
<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"
|
||||
aria-label="Close fullscreen view"
|
||||
>
|
||||
<svg
|
||||
className="w-6 h-6"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<svg className="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
|
|
|
|||
Loading…
Reference in New Issue