Skip to content

Commit

Permalink
fix(VSlider): set correct value when using negative min and 0
Browse files Browse the repository at this point in the history
fixes #7320
  • Loading branch information
johnleider committed May 30, 2019
1 parent c1b0a25 commit 928a518
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vuetify/src/components/VSlider/VSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ export default mixins<options &
return this.lazyValue
},
set (val: number) {
val = isNaN(val) ? 0 : val
// Round value to ensure the
// entire slider range can
// be selected with step
const value = this.roundValue(Math.min(Math.max(val || this.minValue, this.minValue), this.maxValue))
const value = this.roundValue(Math.min(Math.max(val, this.minValue), this.maxValue))

if (value === this.lazyValue) return

Expand Down
13 changes: 13 additions & 0 deletions packages/vuetify/src/components/VSlider/__tests__/VSlider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,4 +550,17 @@ describe('VSlider.ts', () => {

expect(parseKeyDown).toHaveBeenCalled()
})

// https://github.com/vuetifyjs/vuetify/issues/7320
it('should set correct value when using negative min and a value of 0', () => {
const wrapper = mountFunction({
propsData: {
min: -20,
max: 20,
value: 0
}
})

expect(wrapper.vm.internalValue).toBe(0)
})
})

0 comments on commit 928a518

Please sign in to comment.