From c6810eb1390c42913eae9ff139f5006f5efab190 Mon Sep 17 00:00:00 2001 From: Adrian Dapprich Date: Tue, 5 May 2026 13:15:46 +0200 Subject: [PATCH] Enable filtering currencies by name. Fixes oss-apps#636. Use the keywords property of CommandItem which can receive extra arguments to filter for. --- src/components/AddExpense/CurrencyPicker.tsx | 12 ++++++++++++ src/components/GeneralPicker.tsx | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/components/AddExpense/CurrencyPicker.tsx b/src/components/AddExpense/CurrencyPicker.tsx index bee56625..4489670b 100644 --- a/src/components/AddExpense/CurrencyPicker.tsx +++ b/src/components/AddExpense/CurrencyPicker.tsx @@ -76,6 +76,17 @@ function CurrencyPickerInner({ [], ); const extractKey = extractValue; + const extractKeywords = useCallback( + (currency: { code: CurrencyCode } | { code: '__CLEAR__' }) => { + if ('__CLEAR__' === currency.code) { + return []; + } + + const translatedName = getCurrencyName(currency.code); + return [translatedName]; + }, + [getCurrencyName], + ); const selectedOption = useCallback( (currency: { code: CurrencyCode } | { code: '__CLEAR__' }) => '__CLEAR__' === currency.code ? currentCurrency === null : currency.code === currentCurrency, @@ -110,6 +121,7 @@ function CurrencyPickerInner({ items={renderedItems} extractValue={extractValue} extractKey={extractKey} + extractKeywords={extractKeywords} selected={selectedOption} render={renderCurrencyItem} /> diff --git a/src/components/GeneralPicker.tsx b/src/components/GeneralPicker.tsx index dee52d04..5c5f642a 100644 --- a/src/components/GeneralPicker.tsx +++ b/src/components/GeneralPicker.tsx @@ -11,6 +11,7 @@ export const GeneralPicker: React.FC<{ items: any[]; extractValue: (item: any) => string; extractKey: (item: any) => string; + extractKeywords?: (item: any) => string[]; selected: (item: any) => boolean; render: (item: any) => React.ReactNode; placeholderText: string; @@ -23,6 +24,7 @@ export const GeneralPicker: React.FC<{ items, extractValue, extractKey, + extractKeywords, render, placeholderText, noOptionsText, @@ -56,6 +58,7 @@ export const GeneralPicker: React.FC<{