From 0f5394fe746d8dff69ccfd5b43128d1c9be23114 Mon Sep 17 00:00:00 2001 From: tplevko Date: Wed, 24 Jul 2024 12:14:42 +0200 Subject: [PATCH] fix(1207): filtering string with empty space --- packages/ui/src/components/Form/CustomAutoFields.tsx | 5 ++--- .../ui/src/components/Form/customField/CustomNestField.tsx | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ui/src/components/Form/CustomAutoFields.tsx b/packages/ui/src/components/Form/CustomAutoFields.tsx index 0bace8765..3e7e9b07a 100644 --- a/packages/ui/src/components/Form/CustomAutoFields.tsx +++ b/packages/ui/src/components/Form/CustomAutoFields.tsx @@ -32,10 +32,9 @@ export function CustomAutoFields({ return createElement(element, props, [createElement(autoField!, { key: '', name: '' })]); } + const cleanQueryTerm = filteredFieldText.replace(/\s/g, '').toLowerCase(); const actualFields = (fields ?? schema.getSubfields()).filter( - (field) => - !omitFields!.includes(field) && - (field === 'parameters' || field.toLowerCase().includes(filteredFieldText.toLowerCase())), + (field) => !omitFields!.includes(field) && (field === 'parameters' || field.toLowerCase().includes(cleanQueryTerm)), ); const actualFieldsSchema = actualFields.reduce((acc: { [name: string]: unknown }, name) => { acc[name] = schema.getField(name); diff --git a/packages/ui/src/components/Form/customField/CustomNestField.tsx b/packages/ui/src/components/Form/customField/CustomNestField.tsx index 04790587d..2204dd92f 100644 --- a/packages/ui/src/components/Form/customField/CustomNestField.tsx +++ b/packages/ui/src/components/Form/customField/CustomNestField.tsx @@ -46,8 +46,9 @@ export const CustomNestField = connectField( ...props }: CustomNestFieldProps) => { const { filteredFieldText, isGroupExpanded } = useContext(FilteredFieldContext); + const cleanQueryTerm = filteredFieldText.replace(/\s/g, '').toLowerCase(); const filteredProperties = Object.entries(props.properties ?? {}).filter((field) => - field[0].toLowerCase().includes(filteredFieldText.toLowerCase()), + field[0].toLowerCase().includes(cleanQueryTerm), ); const actualProperties = Object.fromEntries(filteredProperties); const propertiesArray = getFieldGroups(actualProperties);