Unverified Commit 87c445f9 authored by Laila Los's avatar Laila Los Committed by davelopez
Browse files

fix reactivity

parent 47c97fde
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
import { library } from "@fortawesome/fontawesome-svg-core";
import { faCheckSquare, faSquare } from "@fortawesome/free-regular-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { toValue } from "@vueuse/core";
import { computed, type ComputedRef, onMounted, type PropType, ref, watch } from "vue";
import Multiselect from "vue-multiselect";

@@ -57,7 +56,7 @@ const emit = defineEmits<{
}>();

const filter = ref("");
const filteredOptions = filterByLabelAndTag();
const filteredOptions = useFilterObjectArray(() => props.options, filter, ["label", ["value", "tags"]]);

/**
 * When there are more options than this, push selected options to the end
@@ -149,7 +148,6 @@ function setInitialValue(): void {
watch(
    () => props.options,
    () => {
        filteredOptions.value = toValue(filterByLabelAndTag());
        setInitialValue();
    }
);
@@ -161,10 +159,6 @@ onMounted(() => {
    setInitialValue();
});

function filterByLabelAndTag() {
    return useFilterObjectArray(() => props.options, filter, ["label", ["value", "tags"]]);
}

function isValueWithTags(item: SelectValue): item is ValueWithTags {
    return item !== null && typeof item === "object" && (item as ValueWithTags).tags !== undefined;
}
+2 −2
Original line number Diff line number Diff line
import { toValue } from "@vueuse/core";
import { Ref, ref } from "vue";
import { computed, Ref } from "vue";

import type { useFilterObjectArray as UseFilterObjectArray } from "@/composables/filter";

@@ -9,5 +9,5 @@ jest.mock("@/composables/filter", () => ({

export const useFilterObjectArray: typeof UseFilterObjectArray = (array): Ref<any[]> => {
    console.debug("USING MOCKED useFilterObjectArray");
    return ref(toValue(array));
    return computed(() => toValue(array));
};