Fix focus issue in Page component when using "/" shortcut

This commit is contained in:
Bram Suurd
2024-05-03 20:21:00 +02:00
parent 5b55921bb8
commit 70eae7467c

View File

@@ -33,12 +33,14 @@ export default function Page() {
const [links, setLinks] = useState<Category[]>([]);
const [searchTerm, setSearchTerm] = useState("");
const [accordionExpanded, setAccordionExpanded] = useState(false);
const inputRef = useRef();
const inputRef = useRef<HTMLInputElement>(null);
useEffect(() => {
const handleKeyDown = (event: any) => {
if (event.key === "/") {
inputRef.current.focus();
if (inputRef.current) {
inputRef.current.focus();
}
event.preventDefault();
}
};