diff --git a/packages/integrations/useSortable/index.ts b/packages/integrations/useSortable/index.ts index b494dd31ebf..da8f01856ba 100644 --- a/packages/integrations/useSortable/index.ts +++ b/packages/integrations/useSortable/index.ts @@ -1,6 +1,7 @@ import { defaultDocument, resolveUnref, tryOnMounted, tryOnScopeDispose, unrefElement } from '@vueuse/core' import type { ConfigurableDocument, MaybeComputedRef } from '@vueuse/core' import Sortable, { type Options } from 'sortablejs' +import { nextTick } from 'vue-demi' export interface UseSortableReturn { /** @@ -62,6 +63,8 @@ export function moveArrayElement( to: number, ): void { const array = resolveUnref(list) - if (to >= 0 && to < array.length) - array.splice(to, 0, array.splice(from, 1)[0]) + if (to >= 0 && to < array.length) { + const element = array.splice(from, 1)[0] + nextTick(() => array.splice(to, 0, element)) + } }