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