nextra icon indicating copy to clipboard operation
nextra copied to clipboard

`Scroll to top` link (`toc.backToTop`) does not show when `toc.float` is enabled

Open junhoyeo opened this issue 1 year ago • 3 comments

Config to reproduce:

...
toc: {
  float: false,
  backToTop: true,
},
editLink: { ... },
feedback: { ... },

Desired behavior:

toc.backToTop should be rendered under editLink and/orfeedback.

junhoyeo avatar Feb 14 '24 23:02 junhoyeo

It seems that they removed "backToTop" from the TOC in a new version. Here's the .d.ts file:

toc?: {
    float?: boolean | undefined;
    component?: ReactNode | FC<TOCProps>;
    extraContent?: ReactNode | FC<{}>;
    title?: ReactNode | FC<{}>;
} | undefined;

And even the floating is not working correctly.

@dimaMachina

mutasim77 avatar Feb 17 '24 04:02 mutasim77

Hey @junhoyeo, I’ve double-checked that the toc.backToTop feature in nextra and nextra-theme-docs v2.13.3 works when you scroll up by at least 300 pixels

Honestly, even I was a bit confused the first time I used it! 😅

Just make sure your page has enough content to scroll.

Here is what actually happening behind the scenes

https://github.com/shuding/nextra/blob/29086aa11874dcf2701b99a2fe4db512de83f8de/packages/nextra-theme-docs/src/components/back-to-top.tsx#L15C6-L16

Esh07 avatar Feb 18 '24 17:02 Esh07

It seems that they removed "backToTop" from the TOC in a new version. Here's the .d.ts file: ... And even the floating is not working correctly.

This is how it's looks like for

  "nextra": "^2.13.3",
  "nextra-theme-docs": "^2.13.3",

node_modules/nextra-theme-docs/dist/index.d.mts


    toc?: {
        backToTop?: boolean | undefined;
        component?: ReactNode | FC<TOCProps>;
        extraContent?: ReactNode | FC;
        float?: boolean | undefined;
        headingComponent?: FC<{
            id: string;
            children: string;
        }> | undefined;
        title?: ReactNode | FC;
    } | undefined;

Esh07 avatar Feb 18 '24 18:02 Esh07

It seems that they removed "backToTop" from the TOC in a new version.

Hey @junhoyeo, I’ve double-checked that the toc.backToTop feature in nextra and nextra-theme-docs v2.13.3 works when you scroll up by at least 300 pixels

"nextra": "3.0.0-alpha.17",
"nextra-theme-docs": "3.0.0-alpha.17",

I'm using the latest alpha version, and I think the backToTop component isn't rendering at all -- dunno about the latest codebase tho. Will take a look...

junhoyeo avatar Feb 19 '24 05:02 junhoyeo