Catalogue item search can hang
Closed this issue · 1 comments
aaronforshaw commented
Description
The catalogue item search page can be provoked to hang with a loading spinner.
See description in #569
pjmonks commented
The issue described in #569 around clearing the date fields is due to these functions in catalogue-search-listing.component.ts
:
// Invoked with { name: 'lastUpdatedAfter', value: null }
onFilterChanged(event: SearchFilterChange) {
this.parameters[event.name] = event.value;
this.updateSearch();
}
updateSearch() {
this.status = 'loading';
this.stateRouter.Go(
'appContainer.mainApp.catalogueSearchListing',
this.parameters
);
}
When navigating to a new state in the UI Router, if the URL ends up being the same as the current URL then nothing will happen by default (but you could force a reload by providing { reloaad: true }
as a router option). To replicate the issue I found:
- Click on the "clear" button in the date filter
- This triggers
onFilterChanged()
passing{ name: 'lastUpdatedAfter', value: null }
- The state router has changed (because of the
null
value - it used to be something different), so the route is transitioned to - Repeating step 1 causes
onFilterChanged()
to be invoked again - This time the state router hasn't detected any change to the new URL, but
updateSearch()
will setthis.state = 'loading'
, forcing the screen to appear to "start searching" - Yet nothing happens - the transition to the route is ignored, hence why the page appears stuck
Simply removing the this.state = 'loading'
line from updateSearch()
should fix this.