Skip to content

Commit

Permalink
Merge pull request #1070 from dpc-sdp/bugfix/R20-1615-no-result-display
Browse files Browse the repository at this point in the history
[R20-1615] don't show no-results message before searching
  • Loading branch information
lambry authored Mar 15, 2024
2 parents b52de20 + b2dfc99 commit 71238c4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<RplContent v-if="searchState.error">
<p>Sorry! Something went wrong. Please try again later.</p>
</RplContent>
<RplContent v-else-if="!searchState.isLoading && !searchState.totalResults">
<RplContent v-else-if="searchComplete && !searchState.totalResults">
<p>Sorry! We couldn't find any matches.</p>
</RplContent>
<div v-else>
Expand Down Expand Up @@ -149,7 +149,7 @@ const searchDriverOptions = {
}
}
const { results, searchState } = await useSearchUI(
const { results, searchState, searchComplete } = await useSearchUI(
apiConnectorOptions,
searchDriverOptions,
[],
Expand Down
9 changes: 7 additions & 2 deletions packages/ripple-tide-search/components/TideSearchPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ const {
searchTermSuggestions,
results,
staticFacetOptions,
filterFormValues
filterFormValues,
searchComplete
} = await useSearchUI(
apiConnectorOptions,
props.searchDriverOptions,
Expand Down Expand Up @@ -300,7 +301,11 @@ watch(
>
<TideSearchError v-if="searchState.error" />
<TideSearchNoResults
v-else-if="!searchState.isLoading && !searchState.totalResults"
v-else-if="
searchComplete &&
!searchState.isLoading &&
!searchState.totalResults
"
:query="searchState.searchTerm"
/>
<RplResultListing v-else>
Expand Down
8 changes: 7 additions & 1 deletion packages/ripple-tide-search/composables/useSearchUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default async (
}, {})
}
})
const searchComplete = ref(false)
const searchDriver = getSearchDriver(apiConnectorOptions, config)
const searchState = ref(searchDriver.getState())
const urlManager = ref(searchDriver.URLManager)
Expand Down Expand Up @@ -72,6 +73,10 @@ export default async (
)

searchDriver.subscribeToStateChanges((state: SearchState) => {
if (!state.isLoading && searchState.value.isLoading) {
searchComplete.value = true
}

searchState.value = state
})

Expand Down Expand Up @@ -140,6 +145,7 @@ export default async (
searchTermSuggestions,
results,
staticFacetOptions,
filterFormValues
filterFormValues,
searchComplete
}
}

0 comments on commit 71238c4

Please sign in to comment.