Skip to content

evaluate/integrate useScrollToTop.ts #16

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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