Skip to content

Commit

Permalink
fix: fix for #60
Browse files Browse the repository at this point in the history
  • Loading branch information
adamberecz committed Dec 20, 2022
1 parent ad1107b commit f7bcd71
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/composables/useSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export default function useSlider (props, context, dependencies)

slider.value.querySelectorAll('[data-handle]').forEach((handle) => {
handle.onblur = () => {
/* istanbul ignore next */
if (!slider.value) {
return
}
Expand Down Expand Up @@ -220,14 +221,22 @@ export default function useSlider (props, context, dependencies)
watch(classes, refresh, { immediate: false, deep: true })

watch(value, (value, old) => {
if (!isNullish(old)) {
// If old was 0, null, undefined, '', false
if (!old) {
return
}

if (
// If both old and new has multiple handles
// and the number of handles decreased
(typeof old === 'object' && typeof value === 'object' && value && Object.keys(old) > Object.keys(value)) ||

// If the old had multiple handles but
// if it decreased to single
(typeof old === 'object' && typeof value !== 'object') ||
!value

// Or has no value at all
isNullish(value)
) {
refresh()
}
Expand Down

0 comments on commit f7bcd71

Please sign in to comment.