Skip to content

Commit d8cdd08

Browse files
authored
Merge pull request #130 from UW-Macrostrat/postgrest-scroll
Postgrest scroll 4.3.8
2 parents c9009a2 + cbeb803 commit d8cdd08

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

packages/ui-components/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [4.3.8] - 2025-07-09
4+
5+
For PostgRESTInfiniteScrollView
6+
7+
- Error handling for newKey
8+
- Allow inputted searchColumns
9+
310
## [4.3.7] - 2025-07-09
411

512
For PostgRESTInfiniteScrollView

packages/ui-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/ui-components",
3-
"version": "4.3.7",
3+
"version": "4.3.8",
44
"description": "UI components for React and Blueprint.js",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

packages/ui-components/src/postgrest-infinite-scroll.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface PostgRESTInfiniteScrollProps extends InfiniteScrollProps<any> {
1414
extraParams?: Record<string, any>;
1515
ascending?: boolean;
1616
filterable?: boolean;
17+
searchColumns?: string[];
1718
order_key?: string;
1819
key?: string;
1920
toggles?: any;
@@ -52,6 +53,7 @@ export function PostgRESTInfiniteScrollView(
5253
extraParams = {},
5354
key,
5455
toggles = null,
56+
searchColumns = undefined,
5557
...rest
5658
} = props;
5759

@@ -64,7 +66,9 @@ export function PostgRESTInfiniteScrollView(
6466
const MultiSelectToUse = MultiSelectComponent ?? MultiSelect;
6567

6668
const res = useAPIResult(route, { limit: 1 });
67-
const [selectedItems, setSelectedItems] = useState<string[]>([]);
69+
const [selectedItems, setSelectedItems] = useState<string[]>(
70+
searchColumns || [],
71+
);
6872
const [filterValue, setFilterValue] = useState<string>("");
6973
const operator1 = ascending ? `asc` : `desc`;
7074
const notOperator1 = ascending ? `desc` : `asc`;
@@ -122,9 +126,9 @@ export function PostgRESTInfiniteScrollView(
122126
return h(Spinner);
123127
}
124128

125-
const keys = Object.keys(res[0] || {}).filter(
126-
(key) => typeof res[0][key] === "string",
127-
);
129+
const keys =
130+
searchColumns ||
131+
Object.keys(res[0] || {}).filter((key) => typeof res[0][key] === "string");
128132

129133
// Filtering function
130134
const filterItem: ItemPredicate<string> = (query, item) =>
@@ -198,8 +202,16 @@ export function PostgRESTInfiniteScrollView(
198202
});
199203
};
200204

205+
const {
206+
toggles: _omitToggles,
207+
SearchBarComponent: _omitSearchBar,
208+
MultiSelectComponent: _omitMultiSelect,
209+
...cleaned
210+
} = props;
211+
201212
const newKey =
202-
key || `${filterValue}-${selectedItems.join(",")}-${JSON.stringify(props)}`;
213+
key ||
214+
`${filterValue}-${selectedItems.join(",")}-${JSON.stringify(cleaned)}`;
203215

204216
return h("div.postgrest-infinite-scroll", [
205217
h("div.header", [

packages/ui-components/stories/postgrest-infinite-scroll.stories.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ Primary.args = {
2525
route: "https://dev.macrostrat.org/api/pg/sources_metadata",
2626
delay: 100,
2727
toggles: h("h1", "Toggles here"),
28+
searchColumns: ["name"],
2829
};

0 commit comments

Comments
 (0)