Skip to content

Commit 5dddbf2

Browse files
authored
Options are now updated via Sortable instance "option" method (#24)
1 parent 8ac1860 commit 5dddbf2

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/components/Sortable.vue

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
import { ref, PropType, watch, onUnmounted, computed } from "vue";
33
import Sortable, { SortableOptions } from "sortablejs";
44
5+
type SortableOptionsProp = Omit<
6+
SortableOptions,
7+
| "onUnchoose"
8+
| "onChoose"
9+
| "onStart"
10+
| "onEnd"
11+
| "onAdd"
12+
| "onUpdate"
13+
| "onSort"
14+
| "onRemove"
15+
| "onFilter"
16+
| "onMove"
17+
| "onClone"
18+
| "onChange"
19+
>;
20+
521
const props = defineProps({
622
/** All SortableJS options are supported; events are handled by the `defineEmits` below and should be used with v-on */
723
options: {
8-
type: Object as PropType<
9-
Omit<
10-
SortableOptions,
11-
| "onUnchoose"
12-
| "onChoose"
13-
| "onStart"
14-
| "onEnd"
15-
| "onAdd"
16-
| "onUpdate"
17-
| "onSort"
18-
| "onRemove"
19-
| "onFilter"
20-
| "onMove"
21-
| "onClone"
22-
| "onChange"
23-
>
24-
>,
24+
type: Object as PropType<SortableOptionsProp>,
2525
default: null,
2626
required: false,
2727
},
@@ -94,7 +94,12 @@ watch(
9494
() => props.options,
9595
(options) => {
9696
if (options && sortable?.value) {
97-
sortable.value.options = { ...sortable.value.options, ...options };
97+
for (const property in options) {
98+
sortable.value.option(
99+
property as keyof SortableOptionsProp,
100+
options[property as keyof SortableOptionsProp]
101+
);
102+
}
98103
}
99104
}
100105
);

0 commit comments

Comments
 (0)