diff --git a/frontend/src/components/Tabs.vue b/frontend/src/components/Tabs.vue index cb479498..f080a372 100644 --- a/frontend/src/components/Tabs.vue +++ b/frontend/src/components/Tabs.vue @@ -3,6 +3,7 @@
{ - sortable = Sortable.create(refTabs.value!!, { - animation: 250, - ghostClass: 'on-sort', - direction: 'horizontal', - onEnd: ({ oldIndex, newIndex }: { oldIndex?: number; newIndex?: number }) => { - swapTab(oldIndex || 0, newIndex || 0) - }, - onMove (event) { - if (event.related && event.dragged) { - if (event.related.classList.contains('fixed') !== event.dragged.classList.contains('fixed')) { - return false - } + sortable = Sortable.create(refTabs.value!!, { + animation: 250, + ghostClass: 'on-sort', + direction: 'horizontal', + onEnd: ({ oldIndex, newIndex }: { oldIndex?: number; newIndex?: number }) => { + swapTab(oldIndex || 0, newIndex || 0) + }, + onMove (event) { + if (event.related && event.dragged) { + if (event.related.classList.contains('fixed') !== event.dragged.classList.contains('fixed')) { + return false } } - }) + } }) } @@ -130,12 +128,16 @@ export default defineComponent({ initSortable() }) - watch(() => props.list, () => { - initSortable() - }) - const tabList = computed(() => sortTabs(props.list)) + watch(tabList, (val) => { + if (sortable && val) { + nextTick(() => { + sortable.sort(val.map(x => x.key)) + }) + } + }) + return { refTabs, switchTab,