Skip to content

Commit

Permalink
fix(Slider): fix change-end emit and support empty array as initial v…
Browse files Browse the repository at this point in the history
…alue (#3320)

* fix(TimePicker): fixed only support hh:mm format

* fix(TimePicker): disabled position only is  start

* fix(Upload): fixed vue error on uploadPastedFiles is false

* docs: add readonly in api

* fix(Slider): change end event not emit

* fix(Slider): range mode not use on value is empty array
  • Loading branch information
myronliu347 authored Sep 17, 2024
1 parent 8eb5448 commit e1634c4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/slider/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ export default mixins(classPrefixMixins).extend({
const { min, max, value } = this;
if (this.range) {
if (Array.isArray(value)) {
this.firstValue = Math.max(min || 0, value[0]);
this.secondValue = Math.min(max || 100, value[1]);
this.firstValue = Math.max(min || 0, value[0] ?? 0);
this.secondValue = Math.min(max || 100, value[1] ?? 0);
} else {
this.firstValue = min || 0;
this.secondValue = max || 100;
Expand Down Expand Up @@ -329,7 +329,7 @@ export default mixins(classPrefixMixins).extend({
},
emitChangeEnd() {
const changeEndValue = this.range ? [this.firstValue, this.secondValue] : this.firstValue;
emitEvent<Parameters<TdSliderProps['onChangeEnd']>>(this, 'changeEnd', changeEndValue);
emitEvent<Parameters<TdSliderProps['onChangeEnd']>>(this, 'change-end', changeEndValue);
},
getStopStyle(position: number) {
return this.vertical ? { top: `calc(${100 - position}% - 1px)` } : { left: `${position}%` };
Expand Down

0 comments on commit e1634c4

Please sign in to comment.