Skip to content

Commit

Permalink
Merge pull request #14139 from itisAliRH/Restore-history-list-scroll-…
Browse files Browse the repository at this point in the history
…position

Get last history list offset and restore on return
  • Loading branch information
mvdbeek authored Jun 22, 2022
2 parents 85d33e3 + fbff9b8 commit 7d57532
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
12 changes: 9 additions & 3 deletions client/src/components/History/CurrentHistory/HistoryPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@
No data found for selected filter.
</b-alert>
</div>
<Listing v-else :items="itemsLoaded" :query-key="queryKey" @scroll="onScroll">
<template v-slot:item="{ item }">
<Listing
v-else
:offset="listOffset"
:items="itemsLoaded"
:query-key="queryKey"
@scroll="onScroll">
<template v-slot:item="{ item, currentOffset }">
<ContentItem
v-if="!invisible[item.hid]"
:id="item.hid"
Expand All @@ -109,7 +114,7 @@
@toggleHighlights="toggleHighlights"
@update:expand-dataset="setExpanded(item, $event)"
@update:selected="setSelected(item, $event)"
@view-collection="$emit('view-collection', item)"
@view-collection="$emit('view-collection', item, currentOffset)"
@delete="onDelete(item)"
@undelete="onUndelete(item)"
@unhide="onUnhide(item)" />
Expand Down Expand Up @@ -165,6 +170,7 @@ export default {
OperationErrorDialog,
},
props: {
listOffset: { type: Number, default: 0 },
history: { type: Object, required: true },
},
data() {
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/History/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<div v-if="currentHistory" id="current-history-panel" class="history-index">
<CurrentHistory
v-if="!breadcrumbs.length"
:list-offset="listOffset"
:history="currentHistory"
v-on="handlers"
@view-collection="onViewCollection">
Expand Down Expand Up @@ -51,10 +52,12 @@ export default {
return {
// list of collections we have drilled down into
breadcrumbs: [],
listOffset: 0,
};
},
methods: {
onViewCollection(collection) {
onViewCollection(collection, currentOffset) {
this.listOffset = currentOffset;
this.breadcrumbs = [...this.breadcrumbs, collection];
},
},
Expand Down
7 changes: 6 additions & 1 deletion client/src/components/History/Layout/Listing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
ref="listing"
class="listing"
data-key="id"
:offset="offset"
:data-sources="items"
:data-component="{}"
@scroll="onScroll">
<template v-slot:item="{ item }">
<slot name="item" :item="item" />
<slot name="item" :item="item" :current-offset="getOffset()" />
</template>
<template v-slot:footer>
<LoadingSpan v-if="loading" class="m-2" message="Loading" />
Expand All @@ -27,6 +28,7 @@ export default {
VirtualList,
},
props: {
offset: { type: Number, default: 0 },
loading: { type: Boolean, default: false },
items: { type: Array, default: null },
queryKey: { type: String, default: null },
Expand Down Expand Up @@ -74,6 +76,9 @@ export default {
const rangeStart = this.$refs.listing.range.start;
this.$emit("scroll", rangeStart);
},
getOffset() {
return this.$refs.listing?.getOffset() || 0;
},
},
};
</script>
Expand Down

0 comments on commit 7d57532

Please sign in to comment.