feat: autofocus input when adding
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user