From 5d6e864451477ab0d11464c1faf75f57242e39a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Wed, 22 May 2024 13:57:57 -0500 Subject: [PATCH] feat: scroll to view home search --- src/app/page.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index f9d74e624..f9ad78a84 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -16,7 +16,7 @@ import { TextField, } from '@radix-ui/themes'; import { go } from 'fuzzysort'; -import { debounce } from 'lodash'; +import { debounce, times } from 'lodash'; import { useRef, useState } from 'react'; import { Link } from '../components/Link'; import { NAVBAR_HEIGHT } from '../components/Navbar'; @@ -148,8 +148,15 @@ export default function Page() { if (!search.current) return; const sanitized = search.current.value.trim(); - setShowSearch(sanitized.length > 0); + + window.scrollTo({ + top: + search.current.getBoundingClientRect().top - + NAVBAR_HEIGHT - + 32, + behavior: 'smooth', + }); }} > @@ -345,6 +352,10 @@ export default function Page() { + {times(64, () => ( +
+ ))} +
);