Skip to content

Commit 61e9231

Browse files
committed
refactored based on recommendations from PR #295
1 parent 9c8f9d2 commit 61e9231

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/components/ScreenAuthors.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import AuthorCardEditing from 'components/AuthorCardEditing.vue'
5959
import AuthorCardViewing from 'components/AuthorCardViewing.vue'
6060
import { AuthorType } from 'src/types'
6161
import { useCff } from 'src/store/cff'
62+
import { scrollToBottom } from '../scroll-to-bottom'
6263
6364
export default defineComponent({
6465
name: 'ScreenAuthors',
@@ -80,9 +81,6 @@ export default defineComponent({
8081
await nextTick()
8182
scrollToBottom()
8283
}
83-
const scrollToBottom = () => {
84-
document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth' })
85-
}
8684
const removeAuthor = () => {
8785
const newAuthors = [...authors.value]
8886
newAuthors.splice(editingId.value, 1)

src/components/ScreenIdentifiers.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import IdentifierCardEditing from 'components/IdentifierCardEditing.vue'
6161
import IdentifierCardViewing from 'components/IdentifierCardViewing.vue'
6262
import { IdentifierType, IdentifierTypeType } from 'src/types'
6363
import { useCff } from 'src/store/cff'
64+
import { scrollToBottom } from '../scroll-to-bottom'
6465
6566
export default defineComponent({
6667
name: 'ScreenIdentifiers',
@@ -92,9 +93,6 @@ export default defineComponent({
9293
setIdentifiers(newIdentifiers)
9394
editingId.value = -1
9495
}
95-
const scrollToBottom = () => {
96-
document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth' })
97-
}
9896
const setIdentifierDescriptionField = (field: keyof IdentifierType, value: string) => {
9997
const identifier = { ...identifiers.value[editingId.value] }
10098
identifier.description = value

src/components/ScreenKeywords.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import StepperActions from 'components/StepperActions.vue'
4949
import Keyword from 'components/Keyword.vue'
5050
import { defineComponent, nextTick } from 'vue'
5151
import { useCff } from '../store/cff'
52+
import { scrollToBottom } from '../scroll-to-bottom'
5253
5354
export default defineComponent({
5455
name: 'ScreenKeywords',
@@ -59,9 +60,6 @@ export default defineComponent({
5960
},
6061
setup () {
6162
const { keywords, setKeywords } = useCff()
62-
const scrollToBottom = () => {
63-
document.getElementsByClassName('bottom')[0].scrollIntoView({ behavior: 'smooth' })
64-
}
6563
const addKeyword = async () => {
6664
const newKeyword = ''
6765
const newKeywords = [...keywords.value, newKeyword]

src/scroll-to-bottom.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const scrollToBottom = (targetClass = 'bottom') => {
2+
document.getElementsByClassName(targetClass)[0].scrollIntoView({
3+
behavior: 'smooth',
4+
block: 'end',
5+
inline: 'end'
6+
})
7+
}

0 commit comments

Comments
 (0)