Skip to content

Commit

Permalink
fix: shifting item retains position
Browse files Browse the repository at this point in the history
Fixes #899
  • Loading branch information
petyosi committed May 8, 2023
1 parent 310e8c0 commit 9fd46ba
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/sizeSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,11 @@ export const sizeSystem = u.system(
u.publish(unshiftWith, offset + affectedGroupCount(offset, groupIndices))
} else if (offset < 0) {
const prevGroupIndicesValue = u.getValue(prevGroupIndices)

if (prevGroupIndicesValue.length > 0) {
u.publish(shiftWith, offset - affectedGroupCount(-offset, prevGroupIndicesValue))
offset -= affectedGroupCount(-offset, prevGroupIndicesValue)
}
u.publish(shiftWith, offset)
}
}
)
Expand Down Expand Up @@ -553,6 +555,10 @@ export const sizeSystem = u.system(
u.map(([shiftWith, sizes, gap]) => {
const groupedMode = sizes.groupIndices.length > 0
if (groupedMode) {
// we can't shift an empty tree
if (empty(sizes.sizeTree)) {
return sizes
}
let newSizeTree = newTree<number>()
const prevGroupIndicesValue = u.getValue(prevGroupIndices)
let removedItemsCount = 0
Expand Down

0 comments on commit 9fd46ba

Please sign in to comment.