Skip to content

Commit

Permalink
🐛 trim submit value for search filter (#1523)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 authored Nov 7, 2023
1 parent f62e032 commit 2ba8a5a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client/src/app/components/FilterToolbar/SearchFilterControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import {
import SearchIcon from "@patternfly/react-icons/dist/esm/icons/search-icon";
import { IFilterControlProps } from "./FilterControl";
import { ISearchFilterCategory } from "./FilterToolbar";
import { inflateSync } from "zlib";

export interface ISearchFilterControlProps<
TItem,
TFilterCategoryKey extends string
TFilterCategoryKey extends string,
> extends IFilterControlProps<TItem, TFilterCategoryKey> {
category: ISearchFilterCategory<TItem, TFilterCategoryKey>;
isNumeric: boolean;
Expand All @@ -36,9 +35,10 @@ export const SearchFilterControl = <TItem, TFilterCategoryKey extends string>({
setInputValue(filterValue?.[0] || "");
}, [filterValue]);

const onFilterSubmit = () =>
// Ignore value with multiple spaces
setFilterValue(inputValue ? [inputValue.replace(/\s+/g, " ")] : []);
const onFilterSubmit = () => {
const trimmedValue = inputValue.trim();
setFilterValue(trimmedValue ? [trimmedValue.replace(/\s+/g, " ")] : []);
};

const id = `${category.key}-input`;
return (
Expand Down

0 comments on commit 2ba8a5a

Please sign in to comment.