浏览代码

fix: fix slider handle flash in control mode (#2442)

代强 1 年之前
父节点
当前提交
eeafecf1f9
共有 2 个文件被更改,包括 7 次插入2 次删除
  1. 6 1
      packages/semi-foundation/slider/foundation.ts
  2. 1 1
      packages/semi-ui/slider/index.tsx

+ 6 - 1
packages/semi-foundation/slider/foundation.ts

@@ -400,7 +400,12 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
         })();
         
         if (Array.isArray(inputValue)) {
-            return [transWay(inputValue[0]), transWay(inputValue[1])];
+            const min = transWay(inputValue[0]);
+            const max = transWay(inputValue[1]);
+            if (min > max) {
+                return this.getState("focusPos") === "min" ? [max, max] : [min, min];
+            }
+            return [min, max];
         } else {
             return transWay(inputValue);
         }

+ 1 - 1
packages/semi-ui/slider/index.tsx

@@ -193,7 +193,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
                 this.setState(stateObj, callback);
             },
             notifyChange: (cbValue: number | number[]) => {
-                this.props.onChange(Array.isArray(cbValue) ? [...cbValue].sort() : cbValue);
+                this.props.onChange(Array.isArray(cbValue) ? [...cbValue].sort((a, b)=>a - b) : cbValue);
             },
             setDragging: (value: boolean[]) => {
                 this.dragging = value;