Skip to content

Commit

Permalink
Fix scroll to resource
Browse files Browse the repository at this point in the history
  • Loading branch information
lookacat committed Jul 8, 2022
1 parent 61e37a9 commit 3d1ede8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import { bus } from 'web-pkg/src/instance'
import { mapActions, mapState, mapMutations } from 'vuex'
import { defineComponent } from '@vue/composition-api'
import MixinFilesListScrolling from '../../mixins/filesListScrolling'
export default defineComponent({
mixins: [MixinFilesListScrolling],
props: {
paginatedResources: {
type: Array,
Expand Down Expand Up @@ -111,6 +113,7 @@ export default defineComponent({
this.resetSelectionCursor()
this.resetFileSelection()
this.addFileSelection({ id: nextId })
this.scrollToResource({ id: nextId })
},
handleShiftClickAction(resource) {
Expand Down Expand Up @@ -166,6 +169,7 @@ export default defineComponent({
// select
this.addFileSelection({ id: nextResourceId })
}
this.scrollToResource({ id: nextResourceId })
this.selectionCursor = this.selectionCursor - 1
},
Expand All @@ -180,6 +184,7 @@ export default defineComponent({
// select
this.addFileSelection({ id: nextResourceId })
}
this.scrollToResource({ id: nextResourceId })
this.selectionCursor = this.selectionCursor + 1
},
Expand Down
9 changes: 2 additions & 7 deletions packages/web-app-files/src/mixins/filesListScrolling.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
export default {
methods: {
scrollToResource(resource) {
const appBar = document.querySelector('#files-app-bar')
let offset = appBar.getBoundingClientRect().bottom

const tableHeader = document.querySelector('.files-table thead')
offset += tableHeader.getBoundingClientRect().height

this.$scrollTo(`.oc-tbody-tr-${resource.getDomSelector()}`, 300, { offset: -offset })
const resourceElement = document.querySelectorAll(`[data-item-id='${resource.id}']`)[0]
resourceElement.scrollIntoView({ block: 'end' })
}
}
}

0 comments on commit 3d1ede8

Please sign in to comment.