feat: Auto-adjust shopping list item autofocus (#7096)

This commit is contained in:
Michael Genson
2026-02-18 16:37:32 -06:00
committed by GitHub
parent ee1205cfdc
commit e9daac5fc4

View File

@@ -30,6 +30,7 @@
:items="foods" :items="foods"
:label="$t('shopping-list.food')" :label="$t('shopping-list.food')"
:icon="$globals.icons.foods" :icon="$globals.icons.foods"
:autofocus="autoFocus === 'food'"
create create
@create="createAssignFood" @create="createAssignFood"
/> />
@@ -41,7 +42,7 @@
:label="$t('shopping-list.note')" :label="$t('shopping-list.note')"
rows="1" rows="1"
auto-grow auto-grow
autofocus :autofocus="autoFocus === 'note'"
@keypress="handleNoteKeyPress" @keypress="handleNoteKeyPress"
/> />
</div> </div>
@@ -165,6 +166,8 @@ export default defineNuxtComponent({
}, },
); );
const autoFocus = !listItem.value.food && listItem.value.note ? "note" : "food";
async function createAssignFood(val: string) { async function createAssignFood(val: string) {
// keep UI reactive // keep UI reactive
// eslint-disable-next-line @typescript-eslint/no-unused-expressions // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -204,6 +207,7 @@ export default defineNuxtComponent({
return { return {
listItem, listItem,
autoFocus,
createAssignFood, createAssignFood,
createAssignUnit, createAssignUnit,
assignLabelToFood, assignLabelToFood,