@internetarchive/collection-browser 4.1.2 → 4.1.3-alpha-webdev8108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -376,6 +376,34 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
376
376
  if (changed.has('searchType') && this.searchType === SearchType.TV) {
377
377
  this.applyDefaultTVSearchSort();
378
378
  }
379
+ // If we need to clear filters due to a query change or other reset, we do so *before* any
380
+ // updates happen, to prevent unnecessary update cycles and ensure there's a clean slate
381
+ // for any search requests that fire.
382
+ if (changed.has('baseQuery') ||
383
+ changed.has('identifiers') ||
384
+ changed.has('searchType') ||
385
+ changed.has('withinCollection')) {
386
+ // Unless this query/search type update is from the initial page load or the
387
+ // result of hitting the back button,
388
+ // we need to clear any existing filters since they may no longer be valid for
389
+ // the new set of search results.
390
+ if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
391
+ // Ordinarily, we leave the sort param unchanged between searches.
392
+ // However, if we are changing the target collection itself, we want the sort cleared too,
393
+ // since different collections may have different sorting options available.
394
+ const shouldClearSort = changed.has('withinCollection') &&
395
+ !changed.has('selectedSort') &&
396
+ !changed.has('sortDirection');
397
+ // Otherwise, only clear filters that haven't been simultaneously applied in this update
398
+ this.clearFilters({
399
+ sort: shouldClearSort,
400
+ facets: !changed.has('selectedFacets'),
401
+ dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
402
+ letterFilters: !(changed.has('selectedTitleFilter') ||
403
+ changed.has('selectedCreatorFilter')),
404
+ });
405
+ }
406
+ }
379
407
  }
380
408
  render() {
381
409
  return html `
@@ -613,8 +641,10 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
613
641
  // Determine the set of sortable fields that should be shown in the sort bar
614
642
  let sortFieldAvailability = defaultSortAvailability;
615
643
  // We adjust the available sort options for a couple of special cases...
616
- if (this.withinCollection?.startsWith('fav-')) {
617
- // When viewing a fav- collection, we include the Date Favorited option as the default
644
+ if (this.withinCollection?.startsWith('fav-') ||
645
+ this.profileElement === 'favorites') {
646
+ // When viewing a fav- collection or the favorites profile tab,
647
+ // we include the Date Favorited option as the default
618
648
  sortFieldAvailability = favoritesSortAvailability;
619
649
  }
620
650
  else if (!this.withinCollection && this.searchType === SearchType.TV) {
@@ -1337,31 +1367,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1337
1367
  changed.has('loggedIn')) {
1338
1368
  this.infiniteScroller?.reload();
1339
1369
  }
1340
- if (changed.has('baseQuery') ||
1341
- changed.has('identifiers') ||
1342
- changed.has('searchType') ||
1343
- changed.has('withinCollection')) {
1344
- // Unless this query/search type update is from the initial page load or the
1345
- // result of hitting the back button,
1346
- // we need to clear any existing filters since they may no longer be valid for
1347
- // the new set of search results.
1348
- if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
1349
- // Ordinarily, we leave the sort param unchanged between searches.
1350
- // However, if we are changing the target collection itself, we want the sort cleared too,
1351
- // since different collections may have different sorting options available.
1352
- const shouldClearSort = changed.has('withinCollection') &&
1353
- !changed.has('selectedSort') &&
1354
- !changed.has('sortDirection');
1355
- // Otherwise, only clear filters that haven't been simultaneously applied in this update
1356
- this.clearFilters({
1357
- sort: shouldClearSort,
1358
- facets: !changed.has('selectedFacets'),
1359
- dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
1360
- letterFilters: !(changed.has('selectedTitleFilter') ||
1361
- changed.has('selectedCreatorFilter')),
1362
- });
1363
- }
1364
- }
1365
1370
  if (changed.has('profileElement')) {
1366
1371
  this.applyDefaultProfileSort();
1367
1372
  }