-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[No QA] Create new filter popups #86906
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
Merged
JS00001
merged 29 commits into
Expensify:main
from
bernhardoj:feat/81558-revamp-search-actions-bar-filters-chip
Apr 9, 2026
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
2822396
prepare new popups and hooks
bernhardoj f6d8c02
add style prop and make label optional
bernhardoj 1c355cd
add sentry label
bernhardoj 989d3d4
add leftelement prop
bernhardoj 8f09fae
rename function
bernhardoj acdf1e6
add more type
bernhardoj 6828bcd
lint
bernhardoj 5722a84
Merge branch 'main' into feat/81558-revamp-search-actions-bar-filters…
bernhardoj bb32693
remove isExpanded prop
bernhardoj 4d5798f
add new sentry label
bernhardoj 23a04f8
Merge branch 'main' into feat/81558-revamp-search-actions-bar-filters…
bernhardoj 5bdd086
update for the new date range filter
bernhardoj 1590a55
fix type error after merge
bernhardoj 812b185
prettier
bernhardoj 0a7bcac
add comment
bernhardoj b533a45
use undefined instead of null
bernhardoj 5e5b641
create basepopup to DRY
bernhardoj 6e9e4fa
minor changes
bernhardoj 8f02a00
lint
bernhardoj cfe7080
make the value generic
bernhardoj 538f99b
prettier
bernhardoj 8c6848e
call openSearchCardFiltersPage when popup is expanded
bernhardoj 0f24839
lint
bernhardoj dac3536
Merge branch 'main' into feat/81558-revamp-search-actions-bar-filters…
bernhardoj 92f3ce8
fix missing param
bernhardoj d997af7
use setState function updater
bernhardoj 0150978
move the style to BasePopup
bernhardoj 434b5a8
Merge branch 'main' into feat/81558-revamp-search-actions-bar-filters…
bernhardoj 44a6a85
remove unused import
bernhardoj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| import React, {useState} from 'react'; | ||
| import type {ValueOf} from 'type-fest'; | ||
| import AmountWithoutCurrencyInput from '@components/AmountWithoutCurrencyInput'; | ||
| import MenuItem from '@components/MenuItem'; | ||
| import type {SearchAmountFilterKeys} from '@components/Search/types'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {convertToBackendAmount, convertToFrontendAmountAsString} from '@libs/CurrencyUtils'; | ||
| import CONST from '@src/CONST'; | ||
| import type {SearchAdvancedFiltersForm} from '@src/types/form'; | ||
| import BasePopup from './BasePopup'; | ||
|
|
||
| type AmountPopupProps = { | ||
| filterKey: SearchAmountFilterKeys; | ||
| label: string; | ||
| value: Record<ValueOf<typeof CONST.SEARCH.AMOUNT_MODIFIERS>, string | undefined>; | ||
| updateFilterForm: (value: Partial<SearchAdvancedFiltersForm>) => void; | ||
| closeOverlay: () => void; | ||
| }; | ||
|
|
||
| type AmountInputProps = { | ||
| title: string; | ||
| value: string; | ||
| name: string; | ||
| onSave: (value: string) => void; | ||
| onBackButtonPress: () => void; | ||
| }; | ||
|
|
||
| function AmountInput({title, value, name, onSave, onBackButtonPress}: AmountInputProps) { | ||
| const styles = useThemeStyles(); | ||
| const [amount, setAmount] = useState(value); | ||
|
|
||
| return ( | ||
| <BasePopup | ||
| label={title} | ||
| onReset={() => onSave('')} | ||
| onApply={() => onSave(amount)} | ||
| resetSentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_RESET_AMOUNT} | ||
| applySentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_APPLY_AMOUNT} | ||
| onBackButtonPress={onBackButtonPress} | ||
| > | ||
| <AmountWithoutCurrencyInput | ||
| containerStyles={[styles.ph4, styles.mb2]} | ||
| defaultValue={amount} | ||
| onInputChange={setAmount} | ||
| label={title} | ||
| accessibilityLabel={title} | ||
| name={name} | ||
| role={CONST.ROLE.PRESENTATION} | ||
| inputMode={CONST.INPUT_MODE.DECIMAL} | ||
| shouldAllowNegative | ||
| autoFocus | ||
| /> | ||
| </BasePopup> | ||
| ); | ||
| } | ||
|
|
||
| function AmountPopup({filterKey, label, value, closeOverlay, updateFilterForm}: AmountPopupProps) { | ||
| const {translate} = useLocalize(); | ||
| const [selectedModifier, setSelectedModifier] = useState<ValueOf<typeof CONST.SEARCH.AMOUNT_MODIFIERS> | null>(null); | ||
| const [amountValues, setAmountValues] = useState(value); | ||
|
|
||
| const title = { | ||
| [CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO]: translate('search.filters.amount.equalTo'), | ||
| [CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN]: translate('search.filters.amount.greaterThan'), | ||
| [CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN]: translate('search.filters.amount.lessThan'), | ||
| }; | ||
|
|
||
| const modifierConfig = [CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO, CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN, CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN]; | ||
|
|
||
| const formatAmount = (amount: string | undefined) => { | ||
| return amount ? convertToFrontendAmountAsString(Number(amount), CONST.DEFAULT_CURRENCY_DECIMALS) : ''; | ||
| }; | ||
|
|
||
| if (selectedModifier) { | ||
| const goBack = () => { | ||
| setSelectedModifier(null); | ||
| }; | ||
|
|
||
| const save = (rawAmount: string) => { | ||
| if (rawAmount.trim() === '') { | ||
| setAmountValues((prevAmountValues) => ({...prevAmountValues, [selectedModifier]: undefined})); | ||
| goBack(); | ||
| return; | ||
| } | ||
|
|
||
| const newAmount = convertToBackendAmount(Number(rawAmount)).toString(); | ||
|
|
||
| // When setting an Equal To value, clear Greater Than and Less Than to avoid conflicting filters. | ||
| if (selectedModifier === CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO) { | ||
| setAmountValues({[CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN]: '', [CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN]: '', [selectedModifier]: newAmount}); | ||
| } | ||
|
|
||
| // When setting Greater Than or Less Than, clear Equal To to avoid conflicting filters. | ||
| if (selectedModifier === CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN || selectedModifier === CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN) { | ||
| setAmountValues((prevAmountValues) => ({...prevAmountValues, [CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO]: '', [selectedModifier]: newAmount})); | ||
| } | ||
| goBack(); | ||
| }; | ||
|
|
||
| return ( | ||
| <AmountInput | ||
| title={title[selectedModifier]} | ||
| value={formatAmount(amountValues[selectedModifier])} | ||
| name={`${filterKey}${selectedModifier}`} | ||
| onBackButtonPress={goBack} | ||
| onSave={save} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| const onChange = (values: Record<ValueOf<typeof CONST.SEARCH.AMOUNT_MODIFIERS>, string | undefined>) => { | ||
| const formValues: Record<string, string | undefined> = {}; | ||
| formValues[`${filterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO}`] = values[CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO]; | ||
| formValues[`${filterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN}`] = values[CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN]; | ||
| formValues[`${filterKey}${CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN}`] = values[CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN]; | ||
| updateFilterForm(formValues); | ||
| closeOverlay(); | ||
| }; | ||
|
|
||
| const applyChanges = () => onChange(amountValues); | ||
|
|
||
| const resetChanges = () => { | ||
| onChange({ | ||
| [CONST.SEARCH.AMOUNT_MODIFIERS.EQUAL_TO]: undefined, | ||
| [CONST.SEARCH.AMOUNT_MODIFIERS.GREATER_THAN]: undefined, | ||
| [CONST.SEARCH.AMOUNT_MODIFIERS.LESS_THAN]: undefined, | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <BasePopup | ||
| label={label} | ||
| onReset={resetChanges} | ||
| onApply={applyChanges} | ||
| resetSentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_RESET_AMOUNT} | ||
| applySentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_POPUP_APPLY_AMOUNT} | ||
| > | ||
| {modifierConfig.map((modifier) => ( | ||
| <MenuItem | ||
| key={modifier} | ||
| title={title[modifier]} | ||
| description={formatAmount(amountValues[modifier])} | ||
| onPress={() => setSelectedModifier(modifier)} | ||
| shouldShowRightIcon | ||
| viewMode={CONST.OPTION_MODE.COMPACT} | ||
| /> | ||
| ))} | ||
| </BasePopup> | ||
| ); | ||
| } | ||
|
|
||
| export default AmountPopup; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import type {StyleProp, ViewStyle} from 'react-native'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import Text from '@components/Text'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import ActionButtons from './ActionButtons'; | ||
|
|
||
| type BasePopupProps = React.PropsWithChildren & { | ||
| label?: string; | ||
| applySentryLabel: string; | ||
| resetSentryLabel: string; | ||
| style?: StyleProp<ViewStyle>; | ||
| onApply: () => void; | ||
| onReset: () => void; | ||
| onBackButtonPress?: () => void; | ||
| }; | ||
|
|
||
| function BasePopup({children, label, applySentryLabel, resetSentryLabel, style, onApply, onReset, onBackButtonPress}: BasePopupProps) { | ||
| // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth | ||
| const {isSmallScreenWidth} = useResponsiveLayout(); | ||
| const styles = useThemeStyles(); | ||
|
|
||
| return ( | ||
| <View style={[!isSmallScreenWidth && styles.pv4, style]}> | ||
| {onBackButtonPress ? ( | ||
| <HeaderWithBackButton | ||
| shouldDisplayHelpButton={false} | ||
| style={[styles.h10, styles.pv1, styles.mb2]} | ||
| subtitle={label} | ||
| onBackButtonPress={onBackButtonPress} | ||
| /> | ||
| ) : ( | ||
| isSmallScreenWidth && !!label && <Text style={[styles.textLabel, styles.textSupporting, styles.ph5, styles.pv1, styles.mb2]}>{label}</Text> | ||
| )} | ||
| {children} | ||
| <ActionButtons | ||
| containerStyle={[styles.flexRow, styles.gap2, styles.ph5, styles.mt2]} | ||
| onReset={onReset} | ||
| onApply={onApply} | ||
| applySentryLabel={applySentryLabel} | ||
| resetSentryLabel={resetSentryLabel} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default BasePopup; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we disabling this rule instead of using
shouldUseNarrowLayout?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this from the existing popup and there is no explanation.
App/src/components/Search/FilterDropdowns/SingleSelectPopup.tsx
Lines 66 to 67 in 48916e2