docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

the backtotopbutton only shows when scrolling up slightly after scrolling down

Open homotechsual opened this issue 1 year ago • 5 comments

Have you read the Contributing Guidelines on issues?

Prerequisites

  • [X] I'm using the latest version of Docusaurus.
  • [X] I have tried the npm run clear or yarn clear command.
  • [X] I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • [X] I have tried creating a repro with https://new.docusaurus.io.
  • [ ] I have read the console error message carefully (if applicable).

Description

After scrolling down the back to top button doesn't show unless you scroll up slightly.

Reproducible demo

No response

Steps to reproduce

  1. Go to https://docusaurus.io/docs/next/api/themes/configuration
  2. Scroll down
  3. Scroll up slightly - note that the backtotopbutton appears.

Expected behavior

The button should appear once scrolling down past the threshold without the need to scroll up slightly.

Actual behavior

The button doesn't appear until you scroll up again slightly.

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • [ ] I'd be willing to fix this bug myself.

homotechsual avatar May 13 '24 17:05 homotechsual

@homotechsual It has been designed that way on purpose in https://github.com/facebook/docusaurus/pull/4912

I'm not against changing it but is it really an improvement considering the button is already quite useless and most modern docs solutions do not have one?

For example VuePress had it, and VitePress doesn't have it, probably because it's not that useful. Do we really want to distract the reading experience with a button that appears? Showing on scroll up is less likely to be distracting so I'm in favor of keeping the current behavior, although it may looks surprising.

slorber avatar May 16 '24 16:05 slorber

There's a certain logic there. The current behaviour feels less discoverable and less intuitive for a user. I'd probably lean towards saying remove it altogether rather than have the current behaviour or make the behaviour (and presence altogether) configurable.

homotechsual avatar May 16 '24 16:05 homotechsual

The current behaviour feels less discoverable and less intuitive for a user.

If a user wants to scroll at the top, he has to scroll up. So, the way to go to the top would actually permit you to discover the feature 😄 .

Have people actually complained about it? Like they didn't know the feature existed or something?

Removing it could annoy some users. Making it configurable could feel a bit overkill. People that don't like this behavior can swizzle the theme component. If nobody swizzled it to implement another behavior, this is probably because the current behavior is not annoying enough for people to take action.

Has anyone in our whole community ever swizzled to disable the button, or change its scroll behavior? If that's the case, I'm more likely to add an option because there's proof the community would use it.

slorber avatar May 16 '24 17:05 slorber

The current behaviour feels less discoverable and less intuitive for a user.

If a user wants to scroll at the top, he has to scroll up. So, the way to go to the top would actually permit you to discover the feature 😄 .

Have people actually complained about it? Like they didn't know the feature existed or something?

Removing it could annoy some users. Making it configurable could feel a bit overkill. People that don't like this behavior can swizzle the theme component. If nobody swizzled it to implement another behavior, this is probably because the current behavior is not annoying enough for people to take action.

Has anyone in our whole community ever swizzled to disable the button, or change its scroll behavior? If that's the case, I'm more likely to add an option because there's proof the community would use it.

These are good questions. It's come up once so far on Discord (which is what prompted this issue) I'm not aware of other discussions - not that that is in and of itself a sign of anything other than I haven't seen them :-)

homotechsual avatar May 16 '24 17:05 homotechsual

Maybe before introducing an option, what we could do is to add that option to the theme-common hook first, so that people can apply the customization easily through swizzle? And if we see people doing it in practice, then we add it to themeConfig?

What would be a good API (for both hook + themeConfig) to make this configurable?

type ScrollToTopConfig = {appearOn: "scroll" | "scroll-up", threshold: number} | null

???

slorber avatar May 16 '24 17:05 slorber

I don't agree this kind of core UX should be customizable. It's a deliberate design decision and gives Docusaurus sites a uniform touch, just like sidebar interactions. I don't think there's sufficient controversy on this to justify extra API surface.

Josh-Cena avatar Jul 19 '24 15:07 Josh-Cena

Agree with @Josh-Cena , let's close this for now.

Users can implement this in userland through swizzle. If we see a few sites unhappy enough about our current behavior to override it through swizzle, this means there is enough traction. Until then, the current behavior is good enough.

slorber avatar Aug 02 '24 08:08 slorber