Skip to content

Commit 3c095e2

Browse files
committed
#397 focus input of editing authors
1 parent 818c2bf commit 3c095e2

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/components/AuthorCardEditing.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
>
77
<div class="row">
88
<q-input
9+
tabindex="1"
910
bg-color="white"
1011
class="col"
1112
dense
@@ -17,6 +18,7 @@
1718
v-bind:error="givenNamesError.hasError"
1819
v-bind:error-message="givenNamesError.messages.join(', ')"
1920
v-on:update:modelValue="$emit('update', 'givenNames', $event)"
21+
ref="givenNamesRef"
2022
/>
2123
</div>
2224
<div class="row">
@@ -153,7 +155,7 @@
153155

154156
<script lang="ts">
155157
/* eslint-disable @typescript-eslint/restrict-template-expressions */
156-
import { computed, defineComponent } from 'vue'
158+
import { computed, defineComponent, onMounted, ref, nextTick } from 'vue'
157159
import { getMyErrors } from 'src/store/validator'
158160
import { authorErrors } from 'src/author-errors'
159161
@@ -198,7 +200,12 @@ export default defineComponent({
198200
}
199201
},
200202
setup (props) {
203+
const givenNamesRef = ref<HTMLElement | null>(null)
204+
onMounted(() => {
205+
givenNamesRef.value?.focus()
206+
})
201207
return {
208+
givenNamesRef,
202209
givenNamesError: computed(() => getMyErrors(`/authors/${props.index}/given-names`)),
203210
nameParticleError: computed(() => getMyErrors(`/authors/${props.index}/name-particle`)),
204211
familyNamesError: computed(() => getMyErrors(`/authors/${props.index}/family-names`)),
@@ -207,6 +214,7 @@ export default defineComponent({
207214
affiliationError: computed(() => getMyErrors(`/authors/${props.index}/affiliation`)),
208215
orcidError: computed(() => getMyErrors(`/authors/${props.index}/orcid`)),
209216
authorErrors: computed(() => authorErrors(props.index))
217+
210218
}
211219
},
212220
emits: ['closePressed', 'removePressed', 'update', 'moveUp', 'moveDown']

0 commit comments

Comments
 (0)