File tree Expand file tree Collapse file tree 2 files changed +4
-12
lines changed
adminforth/spa/src/components Expand file tree Collapse file tree 2 files changed +4
-12
lines changed Original file line number Diff line number Diff line change 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' ,
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 >
Original file line number Diff line number Diff line change 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 >
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 (() => {
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 });
You can’t perform that action at this time.
0 commit comments