Skip to content

Commit f19858b

Browse files
authored
Merge pull request #15439 from smithrashell/fix/go-to-top-button
Fix go to top [Fixes #15412]
2 parents 107cbc3 + aafe223 commit f19858b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/components/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ const Footer = ({ lastDeployLocaleTimestamp }: FooterProps) => {
316316
<Button
317317
variant="outline"
318318
isSecondary
319-
onClick={() => scrollIntoView("__next")}
319+
onClick={() => scrollIntoView("body")}
320320
>
321321
<IoChevronUpSharp /> Go to top
322322
</Button>

src/components/ui/buttons/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
105105
ref
106106
) => {
107107
const handleOnClick = (e: React.MouseEvent<HTMLButtonElement>) => {
108-
toId && scrollIntoView(toId)
108+
toId && scrollIntoView("#" + toId)
109109
customEventOptions && trackCustomEvent(customEventOptions)
110110

111111
onClick?.(e)

src/lib/utils/scrollIntoView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export const scrollIntoView = (
2-
toId: string,
2+
selector: string,
33
options: ScrollIntoViewOptions = { behavior: "smooth", block: "start" }
44
): void => {
5-
const element = document.getElementById(toId)
5+
const element = document.querySelector(selector)
66

77
if (!element) return
88

0 commit comments

Comments
 (0)