Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

[MISC] Clear search filter when switching adapter settings pages (#1712)

Chandrasekharan Maa37eb8be7ac
diff --git a/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx b/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx
index e3d45066d..ae0864d70 100644
--- a/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx
+++ b/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx
@@ -15,6 +15,7 @@ function ToolNavBar({
segmentFilter,
segmentOptions,
onSearch,
+ searchKey,
}) {
const navigate = useNavigate();
const onSearchDebounce = debounce(({ target: { value } }) => {
@@ -55,6 +56,7 @@ function ToolNavBar({
<Col>
{enableSearch && (
<Search
+ key={searchKey}
className="api-search-input"
placeholder="Search by name"
onChange={onSearchDebounce}
@@ -76,6 +78,7 @@ ToolNavBar.propTypes = {
segmentOptions: PropTypes.array,
segmentFilter: PropTypes.func,
onSearch: PropTypes.func,
+ searchKey: PropTypes.string,
};
export { ToolNavBar };
diff --git a/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx b/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx
index d649e210b..e44f3c148 100644
--- a/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx
+++ b/frontend/src/components/tool-settings/tool-settings/ToolSettings.jsx
@@ -54,9 +54,11 @@ function ToolSettings({ type }) {
setMasterList,
updateMasterList,
onSearch,
+ clearSearch,
} = useListSearch("adapter_name");
useEffect(() => {
+ clearSearch();
setMasterList([]);
if (!type) {
return;
@@ -226,6 +228,7 @@ function ToolSettings({ type }) {
<ToolNavBar
title={titles[type]}
enableSearch
+ searchKey={type}
setSearchList={setDisplayList}
onSearch={onSearch}
CustomButtons={() => {
diff --git a/frontend/src/hooks/useListSearch.js b/frontend/src/hooks/useListSearch.js
index c8f9ad13a..3ad6c5511 100644
--- a/frontend/src/hooks/useListSearch.js
+++ b/frontend/src/hooks/useListSearch.js
@@ -33,6 +33,11 @@ function useListSearch(searchField) {
[filterList]
);
+ const clearSearch = useCallback(() => {
+ searchTextRef.current = "";
+ setDisplayList(listRef.current);
+ }, []);
+
const updateMasterList = useCallback(
(updateFn) => {
const updatedList = updateFn(listRef.current);
@@ -49,6 +54,7 @@ function useListSearch(searchField) {
setMasterList,
updateMasterList,
onSearch,
+ clearSearch,
};
}