Skip to content

Commit

Permalink
Fix ScrollYOffset reset when not using a selector (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff1010322 committed Apr 4, 2022
1 parent e812293 commit 420c404
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-panthers-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'docusaurus-theme-redoc': patch
---

fix scrollYOffset disable when not using selector
7 changes: 5 additions & 2 deletions packages/docusaurus-theme-redoc/src/utils/useSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ export function useSpec({ spec, url }: SpecProps) {
const { lightTheme, darkTheme, options: redocOptions } = themeOptions;

const commonOptions: Partial<RedocRawOptions> = {
// Disable offset when server rendering
scrollYOffset: isBrowser ? redocOptions.scrollYOffset : 0,
// Disable offset when server rendering and set to selector
scrollYOffset:
!isBrowser && typeof redocOptions.scrollYOffset === 'string'
? 0
: redocOptions.scrollYOffset,
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down

1 comment on commit 420c404

@vercel
Copy link

@vercel vercel bot commented on 420c404 Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.