feat: scroll to view home search

This commit is contained in:
TrèsAbhi committed 2024-05-22 13:57:57 -05:00
1 parent be7b00c4be
commit 5d6e864451
1 file changed
+13 -2
+13 -2
View File
@@ -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',
});
}}
>
<TextField.Slot>
@@ -345,6 +352,10 @@ export default function Page() {
</Flex>
</Flex>
{times(64, () => (
<br />
))}
<div style={{ flex: 1 }} />
</>
);