fix(web): keep focus on the item input when adding with the + button
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,6 +60,7 @@ export function CreateItemForm({ listId, autoFocus = false }: CreateItemFormProp
|
|||||||
// can be typed in a row; if the request fails the text comes back with the error.
|
// can be typed in a row; if the request fails the text comes back with the error.
|
||||||
const onSubmit = form.handleSubmit((values) => {
|
const onSubmit = form.handleSubmit((values) => {
|
||||||
form.reset()
|
form.reset()
|
||||||
|
form.setFocus('name')
|
||||||
createItem.mutate(values, {
|
createItem.mutate(values, {
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
form.setValue('name', values.name)
|
form.setValue('name', values.name)
|
||||||
@@ -97,6 +98,9 @@ export function CreateItemForm({ listId, autoFocus = false }: CreateItemFormProp
|
|||||||
size="icon-sm"
|
size="icon-sm"
|
||||||
aria-label="Agregar"
|
aria-label="Agregar"
|
||||||
className="size-10 rounded-full"
|
className="size-10 rounded-full"
|
||||||
|
// Tapping the button must not steal the focus from the input: on mobile that
|
||||||
|
// would close the keyboard between one item and the next.
|
||||||
|
onMouseDown={(event) => event.preventDefault()}
|
||||||
>
|
>
|
||||||
<PlusIcon className="size-5" strokeWidth={2.5} />
|
<PlusIcon className="size-5" strokeWidth={2.5} />
|
||||||
</InputGroupButton>
|
</InputGroupButton>
|
||||||
|
|||||||
Reference in New Issue
Block a user