@fluid-topics/ft-reader-context 2.2.20 → 2.2.24

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.
@@ -27,7 +27,7 @@ export declare class FtReaderContext extends FtLitElementRedux implements FtRead
27
27
  readerServiceProvider?: () => Promise<FtReaderService>;
28
28
  tocFilteringContext?: FtSearchContext;
29
29
  constructor();
30
- protected render(): import("lit-html").TemplateResult<1>;
30
+ protected render(): import("lit").TemplateResult<1>;
31
31
  private importStyleIfNeeded;
32
32
  private _stateManager?;
33
33
  get stateManager(): FtReaderStateManager;
@@ -41,10 +41,13 @@ export class FtReaderContext extends FtLitElementRedux {
41
41
  .filters=${this.filters}
42
42
  @ft-search-request-change=${(e) => {
43
43
  var _a;
44
+ e.stopPropagation();
44
45
  if (e.target === this.tocFilteringContext) {
45
46
  this.stateManager.setFilters((_a = e.detail.metadataFilters.filter((m) => m.key != "ft:publicationId")) !== null && _a !== void 0 ? _a : []);
46
47
  }
47
- }} }
48
+ }}
49
+ @ft-search-results-change=${(e) => e.stopPropagation()}
50
+ @search-context-clear-all-filters=${(e) => e.stopPropagation()}
48
51
  >
49
52
  <slot @register-ft-reader-component=${this.registerComponent}></slot>
50
53
  </ft-toc-filtering-search-context>
@@ -108,6 +111,14 @@ export class FtReaderContext extends FtLitElementRedux {
108
111
  if (props.has("readerServiceProvider") && this.readerServiceProvider) {
109
112
  this.stateManager.initService(this.readerServiceProvider);
110
113
  }
114
+ // metadataFilters is never set to undefined, props.get("metadatFilters") is only undefined at the 1st lit lifecycle, for the [] default value init - we do not want to take it as a filter change
115
+ const filtersChanged = props.has("metadataFilters") && props.get("metadataFilters") != undefined;
116
+ if (filtersChanged) {
117
+ // Must run before setMapId: setMapId's reload()/clear() synchronously dispatches store actions
118
+ // that re-sync this.metadataFilters from the store; running this after would re-read the
119
+ // stale pre-change value mid-update() and silently drop the change.
120
+ this.stateManager.setFilters((_a = this.metadataFilters) !== null && _a !== void 0 ? _a : []);
121
+ }
111
122
  if (props.has("mapId") && this.mapId) {
112
123
  this.stateManager.setMapId(this.mapId);
113
124
  this.lastNotifiedNotFoundRelative = undefined;
@@ -115,11 +126,6 @@ export class FtReaderContext extends FtLitElementRedux {
115
126
  if (props.has("searchInDocumentQuery") && this.searchInDocumentQuery != null) {
116
127
  this.stateManager.setSearchInDocumentQuery(this.searchInDocumentQuery);
117
128
  }
118
- // metadataFilters is never set to undefined, props.get("metadatFilters") is only undefined at the 1st lit lifecycle, for the [] default value init - we do not want to take it as a filter change
119
- const filtersChanged = props.has("metadataFilters") && props.get("metadataFilters") != undefined;
120
- if (filtersChanged) {
121
- this.stateManager.setFilters((_a = this.metadataFilters) !== null && _a !== void 0 ? _a : []);
122
- }
123
129
  // reload() re-navigates to the current target once the filtered data is loaded,
124
130
  // so it must not race with a direct navigateToTarget() call from this same update.
125
131
  if (props.has("session")) {