From e26e5e25ce688a9a33b34f53a1a3ce218be3795c Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Sat, 17 Aug 2024 03:13:45 +0300 Subject: [PATCH] fix: slider not normalizing value to array if multiple thumbs exist --- packages/core/src/useSlider/slider.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/useSlider/slider.ts b/packages/core/src/useSlider/slider.ts index aeca76a9..5ab251dd 100644 --- a/packages/core/src/useSlider/slider.ts +++ b/packages/core/src/useSlider/slider.ts @@ -1,7 +1,7 @@ import { InjectionKey, computed, onBeforeUnmount, provide, ref, toValue } from 'vue'; import { useLabel } from '../a11y/useLabel'; import { AriaLabelableProps, Arrayable, Direction, Orientation, Reactivify, TypedSchema } from '../types'; -import { isNullOrUndefined, normalizeProps, useUniqId, withRefCapture } from '../utils/common'; +import { isNullOrUndefined, normalizeArrayable, normalizeProps, useUniqId, withRefCapture } from '../utils/common'; import { toNearestMultipleOf } from '../utils/math'; import { useLocale } from '../i18n/useLocale'; import { useFormField } from '../useFormField'; @@ -142,12 +142,12 @@ export function useSlider(_props: Reactivify) { return; } - if (!Array.isArray(fieldValue.value)) { + if (thumbs.value.length <= 1) { setValue(value); return; } - const nextValue = [...fieldValue.value]; + const nextValue = normalizeArrayable(fieldValue.value).filter(v => !isNullOrUndefined(v)); nextValue[idx] = value; setValue(nextValue); }