Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix search not applied on production environment #493

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-staking",
"version": "0.3.19",
"version": "0.3.20",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ export const FinalityProviderSearch: React.FC<FinalityProviderSearchProps> = ({
const searchParams = useSearchParams();
const initialSearchFp = searchParams.get("fp");

const [searchTerm, setSearchTerm] = useState(initialSearchFp);
const [searchTerm, setSearchTerm] = useState(initialSearchFp || "");
const debouncedSearchTerm = useDebounce(searchTerm, 300);

// Effect for handling initial search
useEffect(() => {
onSearch(debouncedSearchTerm ?? "");
if (initialSearchFp) {
onSearch(initialSearchFp);
}
}, [initialSearchFp, onSearch]);

// Effect for handling subsequent searches
useEffect(() => {
onSearch(debouncedSearchTerm);
}, [debouncedSearchTerm, onSearch]);
jeremy-babylonlabs marked this conversation as resolved.
Show resolved Hide resolved

const handleSearch = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand All @@ -34,7 +42,7 @@ export const FinalityProviderSearch: React.FC<FinalityProviderSearchProps> = ({
<input
type="text"
placeholder="Search by Name or Public Key"
value={searchTerm ?? ""}
value={searchTerm}
onChange={handleSearch}
className="w-full pl-10 pr-4 py-2 text-sm bg-transparent border-b border-gray-300 focus:outline-none focus:border-primary"
/>
Expand Down