Skip to content

Commit 4220df3

Browse files
authored
Merge pull request #168 from UW-Macrostrat/postgrest
onSearchChange for PostgRESTInfiniteScrollView
2 parents b6a200e + d93c8e6 commit 4220df3

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

packages/ui-components/CHANGELOG.md

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

3+
## [4.4.6] - 2025-08-13
4+
5+
onSearchChange for PostgRESTInfiniteScrollView
6+
37
## [4.4.5] - 2025-08-12
48

59
Fix broken Pagination component

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.4.5",
3+
"version": "4.4.6",
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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import hyper from "@macrostrat/hyper";
22
import { InfiniteScrollProps, InfiniteScrollView } from "./infinite-scroll";
33
import { useAPIResult } from "./api";
4-
import { useMemo, useState } from "react";
4+
import { useMemo, useState, useEffect } from "react";
55
import { MultiSelect, ItemRenderer, ItemPredicate } from "@blueprintjs/select";
66
import {
77
MenuItem,
@@ -45,6 +45,7 @@ interface PostgRESTInfiniteScrollProps extends InfiniteScrollProps<any> {
4545
title: string;
4646
children: React.ReactNode;
4747
}>;
48+
onSearchChange: (value: string) => void;
4849
}
4950

5051
export function PostgRESTInfiniteScrollView(
@@ -70,6 +71,7 @@ export function PostgRESTInfiniteScrollView(
7071
searchColumns = undefined,
7172
group_key = undefined,
7273
filter_threshold = 0,
74+
onSearchChange = () => {},
7375
...rest
7476
} = props;
7577

@@ -82,6 +84,11 @@ export function PostgRESTInfiniteScrollView(
8284
);
8385

8486
const [filterValue, setFilterValue] = useState<string>("");
87+
88+
useEffect(() => {
89+
onSearchChange(filterValue);
90+
}, [filterValue]);
91+
8592
const hideData = filterValue.length < filter_threshold;
8693

8794
const SearchBarToUse = SearchBarComponent ?? SearchBar;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Primary.args = {
2626
delay: 100,
2727
toggles: h("h1", "Toggles here"),
2828
searchColumns: [{ value: "name", label: "Name" }],
29+
onSearchChange: (e) => console.log("Search changed:", e),
2930
};
3031

3132
export const Multiselect = Template.bind({});

0 commit comments

Comments
 (0)