Skip to content

Commit

Permalink
fix: 回滚mutators.move行为 (#984)
Browse files Browse the repository at this point in the history
* fix: rollback the behavior of mutators.move and add mutators.swap

* fix: issue fix
  • Loading branch information
soulwu authored Aug 3, 2020
1 parent 804908e commit 010e149
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/core/src/externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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)
Expand Down

0 comments on commit 010e149

Please sign in to comment.