@seekora-ai/ui-sdk-react 0.2.23 → 0.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.
- package/dist/index.umd.js +1 -1
- package/dist/src/index.esm.js +26 -14
- package/dist/src/index.esm.js.map +1 -1
- package/dist/src/index.js +26 -14
- package/dist/src/index.js.map +1 -1
- package/package.json +3 -3
package/dist/src/index.js
CHANGED
|
@@ -303,6 +303,7 @@ class SearchStateManager {
|
|
|
303
303
|
constructor(config) {
|
|
304
304
|
this.listeners = [];
|
|
305
305
|
this.debounceTimer = null;
|
|
306
|
+
this.notifyScheduled = false;
|
|
306
307
|
this.client = config.client;
|
|
307
308
|
this.autoSearch = config.autoSearch !== false;
|
|
308
309
|
this.debounceMs = config.debounceMs || 300;
|
|
@@ -550,19 +551,27 @@ class SearchStateManager {
|
|
|
550
551
|
this.state = { ...this.state, ...updates };
|
|
551
552
|
this.notifyListeners();
|
|
552
553
|
}
|
|
553
|
-
// Notify all listeners of state changes
|
|
554
|
+
// Notify all listeners of state changes, batched via microtask.
|
|
555
|
+
// Multiple synchronous mutations (e.g. addRefinement + page reset)
|
|
556
|
+
// coalesce into a single listener notification.
|
|
554
557
|
notifyListeners() {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
|
|
558
|
+
if (this.notifyScheduled)
|
|
559
|
+
return;
|
|
560
|
+
this.notifyScheduled = true;
|
|
561
|
+
queueMicrotask(() => {
|
|
562
|
+
this.notifyScheduled = false;
|
|
563
|
+
const state = this.getState();
|
|
564
|
+
this.listeners.forEach(listener => {
|
|
565
|
+
try {
|
|
566
|
+
listener(state);
|
|
567
|
+
}
|
|
568
|
+
catch (err) {
|
|
569
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
570
|
+
log.error('SearchStateManager: Error in listener', {
|
|
571
|
+
error: error.message,
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
});
|
|
566
575
|
});
|
|
567
576
|
}
|
|
568
577
|
/** Explicitly clear results (bypasses keepResultsOnClear) */
|
|
@@ -608,10 +617,13 @@ class SearchStateManager {
|
|
|
608
617
|
async fetchFilters(options) {
|
|
609
618
|
log.verbose('SearchStateManager: Fetching filters', { options });
|
|
610
619
|
try {
|
|
611
|
-
|
|
620
|
+
// Do NOT pass refinement-based filters to the Filters API.
|
|
621
|
+
// Facets should be generated from the search query only, not narrowed
|
|
622
|
+
// by active filter selections. This keeps facet options stable when
|
|
623
|
+
// users toggle filters (same behaviour as performSimplifiedFacetSearch
|
|
624
|
+
// in the search API).
|
|
612
625
|
const response = await this.client.getFilters({
|
|
613
626
|
q: this.state.query || undefined,
|
|
614
|
-
filter: filterString || undefined,
|
|
615
627
|
...options,
|
|
616
628
|
});
|
|
617
629
|
log.info('SearchStateManager: Filters fetched', {
|