From 165eb206d9c03e370d8f106fd0908677f81c335d Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Mon, 22 Jan 2024 11:29:34 +0000 Subject: [PATCH] If the filter has changed, re-fetch (#12625) * If the filter has changed, re-fetch * lint * Clear value when filter changes --- .../src/components/app/forms/RelationshipField.svelte | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/client/src/components/app/forms/RelationshipField.svelte b/packages/client/src/components/app/forms/RelationshipField.svelte index fcdc93020e..af48183c20 100644 --- a/packages/client/src/components/app/forms/RelationshipField.svelte +++ b/packages/client/src/components/app/forms/RelationshipField.svelte @@ -108,8 +108,16 @@ } } + $: forceFetchRows(filter) $: debouncedFetchRows(searchTerm, primaryDisplay, defaultValue) + const forceFetchRows = async () => { + // if the filter has changed, then we need to reset the options, clear the selection, and re-fetch + optionsObj = {} + fieldApi.setValue([]) + selectedValue = [] + debouncedFetchRows(searchTerm, primaryDisplay, defaultValue) + } const fetchRows = async (searchTerm, primaryDisplay, defaultVal) => { const allRowsFetched = $fetch.loaded &&