@stoker-platform/web-app 0.5.162 → 0.5.163
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/List.tsx +14 -4
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/List.tsx
CHANGED
|
@@ -635,10 +635,19 @@ export function List({
|
|
|
635
635
|
return [selectColumnDef, ...fieldColumns]
|
|
636
636
|
}, [fields, isPreloadCacheEnabled, isServerReadOnly, recordTitleField, connectionStatus])
|
|
637
637
|
|
|
638
|
+
const isSearchRelevanceOrder = !!(search && isPreloadCacheEnabled)
|
|
639
|
+
|
|
638
640
|
const searchList = useMemo(() => {
|
|
639
641
|
if (search && (isPreloadCacheEnabled || isServerReadOnly)) {
|
|
640
|
-
const searchResults = localFullTextSearch(collection, search, list || [])
|
|
641
|
-
|
|
642
|
+
const searchResults = localFullTextSearch(collection, search, list || [])
|
|
643
|
+
if (isPreloadCacheEnabled) {
|
|
644
|
+
const recordsById = new Map((list || []).map((record) => [record.id, record]))
|
|
645
|
+
return searchResults
|
|
646
|
+
.map((result) => recordsById.get(result.id))
|
|
647
|
+
.filter((record): record is StokerRecord => record !== undefined)
|
|
648
|
+
}
|
|
649
|
+
const searchResultIds = searchResults.map((result) => result.id)
|
|
650
|
+
return list?.filter((record) => searchResultIds.includes(record.id)) || []
|
|
642
651
|
}
|
|
643
652
|
return list || []
|
|
644
653
|
}, [isPreloadCacheEnabled, isServerReadOnly, list, search])
|
|
@@ -658,6 +667,7 @@ export function List({
|
|
|
658
667
|
getCoreRowModel: getCoreRowModel(),
|
|
659
668
|
getPaginationRowModel: getPaginationRowModel(),
|
|
660
669
|
onSortingChange: (sortingUpdater) => {
|
|
670
|
+
if (isSearchRelevanceOrder) return
|
|
661
671
|
if (typeof sortingUpdater === "function") {
|
|
662
672
|
const newSorting = sortingUpdater(sorting)
|
|
663
673
|
const field = getField(fields, newSorting[0].id)
|
|
@@ -697,9 +707,9 @@ export function List({
|
|
|
697
707
|
onRowSelectionChange: setRowSelection,
|
|
698
708
|
pageCount,
|
|
699
709
|
autoResetPageIndex: false,
|
|
700
|
-
enableSorting:
|
|
710
|
+
enableSorting: !isSearchRelevanceOrder,
|
|
701
711
|
state: {
|
|
702
|
-
sorting,
|
|
712
|
+
sorting: isSearchRelevanceOrder ? [] : sorting,
|
|
703
713
|
columnFilters,
|
|
704
714
|
rowSelection,
|
|
705
715
|
pagination: {
|