Skip to content

Commit ad3844c

Browse files
committed
fix: sort views after scrolling so text selection is correct, closes #359
1 parent 470e480 commit ad3844c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/components/RecycleScroller.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ export default {
456456
457457
if (this.emitUpdate) this.$emit('update', startIndex, endIndex)
458458
459+
// After the user has finished scrolling
460+
// Sort views so text selection is correct
461+
clearTimeout(this.$_sortTimer)
462+
this.$_sortTimer = setTimeout(this.sortViews, 300)
463+
459464
return {
460465
continuous,
461466
}
@@ -558,6 +563,12 @@ export default {
558563
})
559564
throw new Error('Rendered items limit reached')
560565
},
566+
567+
sortViews () {
568+
this.pool.sort((viewA, viewB) => viewA.nr.index - viewB.nr.index)
569+
// Remove text selections as they will most likely be wrong or partial
570+
window.getSelection().removeAllRanges()
571+
},
561572
},
562573
}
563574
</script>

0 commit comments

Comments
 (0)