Skip to content

Commit 420c404

Browse files
authored
Fix ScrollYOffset reset when not using a selector (#163)
1 parent e812293 commit 420c404

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/fuzzy-panthers-wink.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'docusaurus-theme-redoc': patch
3+
---
4+
5+
fix scrollYOffset disable when not using selector

packages/docusaurus-theme-redoc/src/utils/useSpec.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ export function useSpec({ spec, url }: SpecProps) {
2424
const { lightTheme, darkTheme, options: redocOptions } = themeOptions;
2525

2626
const commonOptions: Partial<RedocRawOptions> = {
27-
// Disable offset when server rendering
28-
scrollYOffset: isBrowser ? redocOptions.scrollYOffset : 0,
27+
// Disable offset when server rendering and set to selector
28+
scrollYOffset:
29+
!isBrowser && typeof redocOptions.scrollYOffset === 'string'
30+
? 0
31+
: redocOptions.scrollYOffset,
2932
};
3033

3134
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)