Fix list drop (#2996)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-04-17 11:22:49 +06:00 committed by GitHub
parent 6d98f9e6b6
commit 6bdb599e35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -222,12 +222,12 @@
ev.stopPropagation() ev.stopPropagation()
ev.preventDefault() ev.preventDefault()
const update: DocumentUpdate<Doc> = {} const update: DocumentUpdate<Doc> = {}
if (dragItemIndex !== undefined) { if (dragItemIndex !== undefined && viewOptions.orderBy[0] === 'rank') {
const prev = limited[dragItemIndex - 1] as DocWithRank const prev = limited[dragItemIndex - 1] as DocWithRank
const next = limited[dragItemIndex + 1] as DocWithRank const next = limited[dragItemIndex + 1] as DocWithRank
try { try {
const newRank = calcRank(prev, next) const newRank = calcRank(prev, next)
if ((dragItem as DocWithRank)?.rank !== newRank) { if ((dragItem.doc as DocWithRank)?.rank !== newRank) {
;(update as any).rank = newRank ;(update as any).rank = newRank
} }
} catch {} } catch {}
@ -241,7 +241,7 @@
if (props !== undefined) { if (props !== undefined) {
for (const key in props) { for (const key in props) {
const value = props[key] const value = props[key]
if ((dragItem as any)[key] !== value) { if ((dragItem.doc as any)[key] !== value) {
;(update as any)[key] = value ;(update as any)[key] = value
} }
} }