From 0c482d10fc6bde08084d055d7359cd0b4e27c310 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 19 Jun 2026 15:27:45 +0800 Subject: [PATCH 01/13] add text filter length validation --- .../ReportFieldFilterContent.tsx | 9 ++- .../SearchAdvancedFiltersContent.tsx | 11 +--- .../TextInputFilterContent.tsx | 34 +++++++++--- .../ReportField/ReportFieldText.tsx | 9 ++- .../FilterComponents/ReportField/index.tsx | 16 ++++-- .../Search/FilterComponents/index.tsx | 55 +------------------ .../FilterDropdowns/ReportFieldPopup.tsx | 5 +- .../FilterDropdowns/TextFilterPopup.tsx | 53 ++++++++++++++++++ .../SearchPageHeader/useSearchFiltersBar.tsx | 16 +++++- .../Search/hooks/useTextFilterValidation.tsx | 27 +++++++++ src/libs/SearchUIUtils.ts | 8 ++- src/types/form/SearchAdvancedFiltersForm.ts | 13 ++++- 12 files changed, 172 insertions(+), 84 deletions(-) create mode 100644 src/components/Search/FilterDropdowns/TextFilterPopup.tsx create mode 100644 src/components/Search/hooks/useTextFilterValidation.tsx diff --git a/src/components/Search/FilterComponents/AdvancedFilters/ReportFieldFilterContent.tsx b/src/components/Search/FilterComponents/AdvancedFilters/ReportFieldFilterContent.tsx index 65fe5e8c09fd..e2e295f28a75 100644 --- a/src/components/Search/FilterComponents/AdvancedFilters/ReportFieldFilterContent.tsx +++ b/src/components/Search/FilterComponents/AdvancedFilters/ReportFieldFilterContent.tsx @@ -1,4 +1,4 @@ -import React, {useRef} from 'react'; +import React, {useRef, useState} from 'react'; import type {StyleProp, ViewStyle} from 'react-native'; import Button from '@components/Button'; import ReportFieldBase from '@components/Search/FilterComponents/ReportField'; @@ -22,6 +22,8 @@ function ReportFieldFilterContent({values, selectedField, largeButton, style, on const styles = useThemeStyles(); const reportFieldRef = useRef(null); + const [error, setError] = useState(); + return ( <> {!!selectedField && ( @@ -40,6 +43,10 @@ function ReportFieldFilterContent({values, selectedField, largeButton, style, on text={translate('common.apply')} pressOnEnter onPress={() => { + if (error) { + return; + } + const value = reportFieldRef.current?.applySelectedFieldAndGoBack(); if (!value) { return; diff --git a/src/components/Search/FilterComponents/AdvancedFilters/SearchAdvancedFiltersContent.tsx b/src/components/Search/FilterComponents/AdvancedFilters/SearchAdvancedFiltersContent.tsx index d4365dbb5518..5712485f5e97 100644 --- a/src/components/Search/FilterComponents/AdvancedFilters/SearchAdvancedFiltersContent.tsx +++ b/src/components/Search/FilterComponents/AdvancedFilters/SearchAdvancedFiltersContent.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import {isAmountFilterKey, isDateFilterKey} from '@libs/SearchUIUtils'; +import {isAmountFilterKey, isDateFilterKey, isTextFilterKey} from '@libs/SearchUIUtils'; import type {SearchFilter} from '@libs/SearchUIUtils'; import CONST from '@src/CONST'; import type {SearchAdvancedFiltersForm} from '@src/types/form'; @@ -39,14 +39,7 @@ function getFilterFormValue(filter function SearchAdvancedFiltersContent({filterKey, values, policyIDQuery, ready, components, onChange}: SearchAdvancedFiltersContentProps) { const {Text: TextFilter, Amount: AmountFilter, Date: DateFilter, ReportField: ReportFieldFilter, Common: CommonFilter} = components; - if ( - filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.MERCHANT || - filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.DESCRIPTION || - filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_ID || - filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.KEYWORD || - filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.TITLE || - filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID - ) { + if (isTextFilterKey(filterKey)) { return ( - void) : undefined} + placeholder={label} value={value} - policyIDs={undefined} - filterKey={filterKey} - policyIDQuery={undefined} - autoFocus={autoFocus} - onChange={(v) => setValue(typeof v === 'string' ? v : undefined)} + errorText={error} + hasError={!!error} + onChangeText={setValue} + accessibilityLabel={label} + role={CONST.ROLE.PRESENTATION} + containerStyles={[styles.ph5]} />