Skip to content

Commit d4887d7

Browse files
committed
fix: Update ColumnValueInputWrapper to focus on the last input after adding an array item
1 parent 40fe9b9 commit d4887d7

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

adminforth/spa/src/components/ColumnValueInputWrapper.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<script setup lang="ts">
5050
import { IconPlusOutline } from '@iconify-prerendered/vue-flowbite';
5151
import ColumnValueInput from "./ColumnValueInput.vue";
52-
import { ref } from 'vue';
52+
import { ref, nextTick } from 'vue';
5353
5454
const props = defineProps<{
5555
source: 'create' | 'edit',
@@ -65,8 +65,9 @@
6565
6666
const arrayItemRefs = ref([]);
6767
68-
function addArrayItem() {
68+
async function addArrayItem() {
6969
props.setCurrentValue(props.column.name, props.currentValues[props.column.name], props.currentValues[props.column.name].length);
70-
emit('focus-last-input', props.column.name);
70+
await nextTick();
71+
arrayItemRefs.value[arrayItemRefs.value.length - 1].focus();
7172
}
7273
</script>

adminforth/spa/src/components/GroupsTable.vue

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
@update:unmasked="unmasked[$event] = !unmasked[$event]"
5454
@update:inValidity="customComponentsInValidity[$event.name] = $event.value"
5555
@update:emptiness="customComponentsEmptiness[$event.name] = $event.value"
56-
@focus-last-input="focusOnLastInput"
5756
/>
5857
<div v-if="columnError(column) && validating" class="mt-1 text-xs text-red-500 dark:text-red-400">{{ columnError(column) }}</div>
5958
<div v-if="column.editingNote && column.editingNote[mode]" class="mt-1 text-xs text-gray-400 dark:text-gray-500">{{ column.editingNote[mode] }}</div>
@@ -85,8 +84,6 @@
8584
columnOptions: any,
8685
}>();
8786
88-
const arrayItemRefs = ref([]);
89-
9087
const customComponentsInValidity: Ref<Record<string, boolean>> = ref({});
9188
const customComponentsEmptiness: Ref<Record<string, boolean>> = ref({});
9289
const allColumnsHaveCustomComponent = computed(() => {
@@ -98,12 +95,6 @@
9895
9996
const emit = defineEmits(['update:customComponentsInValidity', 'update:customComponentsEmptiness']);
10097
101-
async function focusOnLastInput(column) {
102-
// wait for element to register
103-
await nextTick();
104-
arrayItemRefs.value[arrayItemRefs.value.length - 1].focus();
105-
}
106-
10798
watch(customComponentsInValidity.value, (newVal) => {
10899
emit('update:customComponentsInValidity', newVal);
109100
});

0 commit comments

Comments
 (0)