Skip to content

evaluate/integrate useScrollToTop.ts #16

@dovholuknf

Description

@dovholuknf

Some projects have been implementing "useScrollToTop.ts"

// src/components/useScrollToTop.ts

import { useEffect } from 'react';
import { useLocation } from '@docusaurus/router';

export function useScrollToTop(): void {
  const location = useLocation();

  useEffect(() => {
    const scrollableElement = document.querySelector('.main-wrapper');
    if (scrollableElement && scrollableElement.scrollTo) {
        scrollableElement.scrollTo(0, 0);
    } else {
        window.scrollTo(0, 0);
    }

  }, [location.pathname]);
}

to work around navigation issues. evaluate if this is a problem in the unified doc and if it is expose this to the shared library (lib/packages/docusaurus-shared)

Then, update the dependent doc projects and remove the non-shared version from each repo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions