5454</template >
5555
5656<script lang="ts">
57- import { defineComponent , ref } from ' vue'
57+ import { defineComponent , nextTick , ref } from ' vue'
5858import Stepper from ' components/Stepper.vue'
5959import StepperActions from ' components/StepperActions.vue'
6060import IdentifierCardEditing from ' components/IdentifierCardEditing.vue'
@@ -73,7 +73,7 @@ export default defineComponent({
7373 setup () {
7474 const { identifiers, setIdentifiers } = useCff ()
7575 const editingId = ref (- 1 )
76- const addIdentifier = () => {
76+ const addIdentifier = async () => {
7777 const newIdentifier: IdentifierType = {
7878 type: ' doi' ,
7979 value: ' ' ,
@@ -82,17 +82,19 @@ export default defineComponent({
8282 const newIdentifiers = [... identifiers .value , newIdentifier ]
8383 setIdentifiers (newIdentifiers )
8484 editingId .value = newIdentifiers .length - 1
85- setTimeout (() => {
86- // FIXME shouldn't have to use a timeout but it seems the DOM doesn't update in time
87- document .getElementsByClassName (' bottom' )[0 ].scrollIntoView ({ behavior: ' smooth' })
88- }, 100 )
85+ // await the DOM update that resulted from updating the identifiers list
86+ await nextTick ()
87+ scrollToBottom ()
8988 }
9089 const removeIdentifier = () => {
9190 const newIdentifiers = [... identifiers .value ]
9291 newIdentifiers .splice (editingId .value , 1 )
9392 setIdentifiers (newIdentifiers )
9493 editingId .value = - 1
9594 }
95+ const scrollToBottom = () => {
96+ document .getElementsByClassName (' bottom' )[0 ].scrollIntoView ({ behavior: ' smooth' })
97+ }
9698 const setIdentifierDescriptionField = (field : keyof IdentifierType , value : string ) => {
9799 const identifier = { ... identifiers .value [editingId .value ] }
98100 identifier .description = value
0 commit comments