Browse Source

Merge branch 'fix-autocomplete-value' into new-pb

xuxin 1 year ago
parent
commit
ac8521ecf1

File diff suppressed because it is too large
+ 0 - 0
vuetifyx/vuetifyxjs/dist/vuetifyxjs.umd.min.js


+ 12 - 6
vuetifyx/vuetifyxjs/src/components/Autocomplete.tsx

@@ -1,10 +1,10 @@
 import Vue, { CreateElement, VNode, VNodeData } from 'vue';
 import draggable from 'vuedraggable';
 import { VAutocomplete, VPagination } from 'vuetify/lib';
-import { Core, SelectedItems, slotTemplates } from './Helpers';
+import { Core, slotTemplates } from './Helpers';
 
 export default Vue.extend({
-	mixins: [Core, SelectedItems],
+	mixins: [Core],
 	components: {
 		vpagination: VPagination,
 		vautocomplete: VAutocomplete,
@@ -86,8 +86,14 @@ export default Vue.extend({
 					}
 				})
 			})
-
-			this.cachedSelectedItems = (cachedSelectedItems) as [];
+			// remove duplicate items
+			const uniqueCachedSelectedItems = cachedSelectedItems.filter((obj, index, self) => {
+				return index === self.findIndex((o) => (
+					o.value === obj.value
+				));
+			});
+			this.cachedSelectedItems = (uniqueCachedSelectedItems) as [];
+			console.log("cachedSelectedItems", this.cachedSelectedItems);
 			this.value = vals;
 			this.$emit("change", vals);
 		},
@@ -106,9 +112,9 @@ export default Vue.extend({
 	},
 
 	created() {
-		this.listItems =  this.$props.items || this.$props.selectedItems || [];
-		this.cachedSelectedItems = this.$props.selectedItems || [];
+		this.listItems =  this.$props.items || [];
 		this.value = (this.$attrs.value) as any || [];
+		this.cachedSelectedItems = this.value;
 	},
 
 	mounted() {

Some files were not shown because too many files changed in this diff