From 010e1495e83a002d734f775e7e45f1f14010865c Mon Sep 17 00:00:00 2001 From: soulwu Date: Mon, 3 Aug 2020 10:25:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=9E=E6=BB=9Amutators.move=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA=20(#984)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: rollback the behavior of mutators.move and add mutators.swap * fix: issue fix --- packages/core/src/externals.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/core/src/externals.ts b/packages/core/src/externals.ts index bbe052c0d3e..d74fbaa43dd 100644 --- a/packages/core/src/externals.ts +++ b/packages/core/src/externals.ts @@ -1064,7 +1064,7 @@ export const createFormExternals = ( shift() { return mutators.remove(0) }, - move($from: number, $to: number) { + swap($from: number, $to: number) { const arr = toArr(getValue()).slice() const fromItem = arr[$from] const toItem = arr[$to] @@ -1073,6 +1073,14 @@ export const createFormExternals = ( setValue(arr) return arr }, + move($from: number, $to: number) { + const arr = toArr(getValue()).slice() + const item = arr[$from] + arr.splice($from, 1) + arr.splice($to, 0, item) + setValue(arr) + return arr + }, moveUp(index: number) { const len = toArr(getValue()).length return mutators.move(index, index - 1 < 0 ? len - 1 : index - 1)