Skip to content

Commit

Permalink
Only set index available when errors are not ignored
Browse files Browse the repository at this point in the history
Fixes an issue that occurs when flipping between sources before they finish loading. When that happens, the existing requests are cancelled, which causes their `catch` blocks to run asyncronously. This results in `setIndexActive` being called after `setIndexBusy` and a loading state that doesn't reflect the actual loading.

Fixes #12595
  • Loading branch information
brianjhanson committed Jan 31, 2023
1 parent 9b483fa commit b4c3273
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/web/assets/cp/src/js/BaseElementIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ Craft.BaseElementIndex = Garnish.Base.extend(
this.selectDefaultSource();
})
.catch(() => {
this.setIndexAvailable();
if (!this._ignoreFailedRequest) {
this.setIndexAvailable();
Craft.cp.displayError(Craft.t('app', 'A server error occurred.'));
}
});
Expand Down Expand Up @@ -876,7 +876,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
},

updateElements: function (preservePagination, pageChanged) {
// Ignore if we're not fully initialized yet
// Ignore if we're not fully initialized yetjhh
if (!this.initialized) {
return;
}
Expand Down Expand Up @@ -917,8 +917,8 @@ Craft.BaseElementIndex = Garnish.Base.extend(
}
})
.catch((e) => {
this.setIndexAvailable();
if (!this._ignoreFailedRequest) {
this.setIndexAvailable();
Craft.cp.displayError(Craft.t('app', 'A server error occurred.'));
}
});
Expand Down

0 comments on commit b4c3273

Please sign in to comment.