Skip to content

Commit 94d956f

Browse files
pczarnDamian Dulisz
authored andcommitted
Fix the predicted number of visible options (shentao#427)
Navigation in the dropdown works with scrolling. Fixes shentao#426
1 parent cec1820 commit 94d956f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/multiselectMixin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,10 @@ export default {
601601

602602
if (hasEnoughSpaceBelow || spaceBelow > spaceAbove || this.openDirection === 'below' || this.openDirection === 'bottom') {
603603
this.prefferedOpenDirection = 'below'
604-
this.optimizedHeight = Math.min(spaceBelow, this.maxHeight) - 40
604+
this.optimizedHeight = Math.min(spaceBelow - 40, this.maxHeight)
605605
} else {
606606
this.prefferedOpenDirection = 'above'
607-
this.optimizedHeight = Math.min(spaceAbove, this.maxHeight) - 40
607+
this.optimizedHeight = Math.min(spaceAbove - 40, this.maxHeight)
608608
}
609609
}
610610
}

src/pointerMixin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ export default {
22
data () {
33
return {
44
pointer: 0,
5-
pointerDirty: false,
6-
visibleElements: this.maxHeight / this.optionHeight
5+
visibleElements: this.optimizedHeight / this.optionHeight,
6+
pointerDirty: false
77
}
88
},
99
props: {
@@ -53,7 +53,7 @@ export default {
5353
if (this.pointer < this.filteredOptions.length - 1) {
5454
this.pointer++
5555
/* istanbul ignore next */
56-
if (this.$refs.list.scrollTop <= this.pointerPosition - this.visibleElements * this.optionHeight) {
56+
if (this.$refs.list.scrollTop <= this.pointerPosition - (this.visibleElements - 1) * this.optionHeight) {
5757
this.$refs.list.scrollTop = this.pointerPosition - (this.visibleElements - 1) * this.optionHeight
5858
}
5959
/* istanbul ignore else */

0 commit comments

Comments
 (0)