MauroDataMapper/mdm-ui

Catalogue item search can hang

Closed this issue · 1 comments

Description

The catalogue item search page can be provoked to hang with a loading spinner.

See description in #569

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:

  1. Click on the "clear" button in the date filter
  2. This triggers onFilterChanged() passing { name: 'lastUpdatedAfter', value: null }
  3. The state router has changed (because of the null value - it used to be something different), so the route is transitioned to
  4. Repeating step 1 causes onFilterChanged() to be invoked again
  5. This time the state router hasn't detected any change to the new URL, but updateSearch() will set this.state = 'loading', forcing the screen to appear to "start searching"
  6. 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.