From 2ba8a5aca8e27a3667ea715e03c390d3275c4c0c Mon Sep 17 00:00:00 2001 From: Ian Bolton Date: Tue, 7 Nov 2023 13:50:31 -0500 Subject: [PATCH] :bug: trim submit value for search filter (#1523) Resolves https://issues.redhat.com/browse/MTA-1487 Signed-off-by: ibolton336 --- .../components/FilterToolbar/SearchFilterControl.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/app/components/FilterToolbar/SearchFilterControl.tsx b/client/src/app/components/FilterToolbar/SearchFilterControl.tsx index 4c36bccc88..d34f9b0751 100644 --- a/client/src/app/components/FilterToolbar/SearchFilterControl.tsx +++ b/client/src/app/components/FilterToolbar/SearchFilterControl.tsx @@ -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 { category: ISearchFilterCategory; isNumeric: boolean; @@ -36,9 +35,10 @@ export const SearchFilterControl = ({ 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 (