import { useEffect, useRef } from 'react';
import { useViewportType } from '../../../useViewportType';
export const useScrollToActiveTab = () => {
    const containerRef = useRef(null);
    const { isMobile } = useViewportType();
    useEffect(() => {
        if (!containerRef.current || !isMobile) {
            return;
        }
        const selectedTab = containerRef.current.querySelector('[aria-selected="true"]');
        const runScroll = () => {
            if (selectedTab) {
                selectedTab.scrollIntoView({
                    behavior: 'smooth',
                });
            }
        };
        // TODO: Убрать setTimeout после отказа от MUI в компоненте
        setTimeout(() => {
            runScroll();
        }, 200);
    }, []);
    return { containerRef };
};
