Skip to content

Commit bad6eba

Browse files
committed
Focus on input when creating a new keyword or identifier
1 parent 4422e9f commit bad6eba

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/components/IdentifierCardEditing.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
v-bind:error-message="valueError.messages.join(', ')"
3434
v-bind:model-value="value"
3535
v-on:update:modelValue="$emit('updateValue', 'value', $event)"
36+
ref="valueRef"
3637
/>
3738
</div>
3839
<div class="q-mt-md items-center no-wrap">
@@ -91,7 +92,7 @@
9192

9293
<script lang="ts">
9394
import { IdentifierTypeType } from '../types'
94-
import { computed, defineComponent, PropType } from 'vue'
95+
import { computed, defineComponent, onMounted, PropType, ref } from 'vue'
9596
import { getMyErrors } from 'src/store/validator'
9697
import { identifierErrors } from 'src/identifier-errors'
9798
import SchemaGuideLink from 'src/components/SchemaGuideLink.vue'
@@ -133,8 +134,12 @@ export default defineComponent({
133134
},
134135
other: { label: 'identifier', anchor: '#definitionsidentifier' }
135136
}
136-
137+
const valueRef = ref<HTMLElement | null>(null)
138+
onMounted(() => {
139+
valueRef.value?.focus()
140+
})
137141
return {
142+
valueRef,
138143
typeOptions: [
139144
{ label: 'DOI', value: 'doi' },
140145
{ label: 'URL', value: 'url' },

src/components/Keyword.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
v-bind:error="keywordError.hasError"
1111
v-bind:error-message="keywordError.messages.join(', ')"
1212
v-on:update:modelValue="$emit('update', $event)"
13+
ref="keywordRef"
1314
/>
1415
</div>
1516
<q-btn
@@ -41,7 +42,7 @@
4142
</template>
4243

4344
<script lang="ts">
44-
import { computed, defineComponent } from 'vue'
45+
import { computed, defineComponent, onMounted, ref } from 'vue'
4546
import { getMyErrors } from 'src/store/validator'
4647
4748
export default defineComponent({
@@ -61,7 +62,12 @@ export default defineComponent({
6162
}
6263
},
6364
setup (props) {
65+
const keywordRef = ref<HTMLElement | null>(null)
66+
onMounted(() => {
67+
keywordRef.value?.focus()
68+
})
6469
return {
70+
keywordRef,
6571
keywordError: computed(() => getMyErrors(`/keywords/${props.index}`))
6672
}
6773
},

0 commit comments

Comments
 (0)