@seekora-ai/ui-sdk-core 0.2.22 → 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.d.ts +1 -0
- package/dist/index.esm.js +26 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +26 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1394,6 +1394,7 @@ class SearchStateManager {
|
|
|
1394
1394
|
constructor(config) {
|
|
1395
1395
|
this.listeners = [];
|
|
1396
1396
|
this.debounceTimer = null;
|
|
1397
|
+
this.notifyScheduled = false;
|
|
1397
1398
|
this.client = config.client;
|
|
1398
1399
|
this.autoSearch = config.autoSearch !== false;
|
|
1399
1400
|
this.debounceMs = config.debounceMs || 300;
|
|
@@ -1641,19 +1642,27 @@ class SearchStateManager {
|
|
|
1641
1642
|
this.state = { ...this.state, ...updates };
|
|
1642
1643
|
this.notifyListeners();
|
|
1643
1644
|
}
|
|
1644
|
-
// Notify all listeners of state changes
|
|
1645
|
+
// Notify all listeners of state changes, batched via microtask.
|
|
1646
|
+
// Multiple synchronous mutations (e.g. addRefinement + page reset)
|
|
1647
|
+
// coalesce into a single listener notification.
|
|
1645
1648
|
notifyListeners() {
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1649
|
+
if (this.notifyScheduled)
|
|
1650
|
+
return;
|
|
1651
|
+
this.notifyScheduled = true;
|
|
1652
|
+
queueMicrotask(() => {
|
|
1653
|
+
this.notifyScheduled = false;
|
|
1654
|
+
const state = this.getState();
|
|
1655
|
+
this.listeners.forEach(listener => {
|
|
1656
|
+
try {
|
|
1657
|
+
listener(state);
|
|
1658
|
+
}
|
|
1659
|
+
catch (err) {
|
|
1660
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
1661
|
+
log.error('SearchStateManager: Error in listener', {
|
|
1662
|
+
error: error.message,
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
});
|
|
1657
1666
|
});
|
|
1658
1667
|
}
|
|
1659
1668
|
/** Explicitly clear results (bypasses keepResultsOnClear) */
|
|
@@ -1699,10 +1708,13 @@ class SearchStateManager {
|
|
|
1699
1708
|
async fetchFilters(options) {
|
|
1700
1709
|
log.verbose('SearchStateManager: Fetching filters', { options });
|
|
1701
1710
|
try {
|
|
1702
|
-
|
|
1711
|
+
// Do NOT pass refinement-based filters to the Filters API.
|
|
1712
|
+
// Facets should be generated from the search query only, not narrowed
|
|
1713
|
+
// by active filter selections. This keeps facet options stable when
|
|
1714
|
+
// users toggle filters (same behaviour as performSimplifiedFacetSearch
|
|
1715
|
+
// in the search API).
|
|
1703
1716
|
const response = await this.client.getFilters({
|
|
1704
1717
|
q: this.state.query || undefined,
|
|
1705
|
-
filter: filterString || undefined,
|
|
1706
1718
|
...options,
|
|
1707
1719
|
});
|
|
1708
1720
|
log.info('SearchStateManager: Filters fetched', {
|