feat: autofocus input when adding

This commit is contained in:
2025-01-26 17:49:32 +00:00
parent df9be06aa6
commit e367182dfa
2 changed files with 26 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import clsx from "clsx"
import { useMemo, useRef, useState } from "react"
import { useEffect, useMemo, useRef, useState } from "react"
import Chart from "react-google-charts"
import { Button } from "~/components/button"
import { ApplicationList } from "~/home/application-list"
@@ -90,6 +90,12 @@ function AddApplicationForm() {
const hasEntry = useStore((state) => state.hasEntry)
const inputRef = useRef<HTMLInputElement | null>(null)
useEffect(() => {
if (isAddingEntry) {
inputRef.current?.focus()
}
}, [isAddingEntry])
function onAddButtonClick() {
if (!isAddingEntry) {
setIsAddingEntry(true)