Skip to content

Commit

Permalink
set header message to not found when list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
aeioual authored Feb 12, 2024
1 parent 74419ef commit 5dc148c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/pages/EditReportFieldDropdownPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ function EditReportFieldDropdownPage({fieldName, onSubmit, fieldID, fieldValue,
const {getSafeAreaMargins} = useStyleUtils();
const {translate} = useLocalize();
const recentlyUsedOptions = useMemo(() => recentlyUsedReportFields?.[fieldID] ?? [], [recentlyUsedReportFields, fieldID]);
const [headerMessage, setHeaderMessage] = useState('');

const sections = useMemo(() => {
const filteredRecentOptions = recentlyUsedOptions.filter((option) => option.toLowerCase().includes(searchValue.toLowerCase()));
const filteredRestOfOptions = fieldOptions.filter((option) => !filteredRecentOptions.includes(option) && option.toLowerCase().includes(searchValue.toLowerCase()));
setHeaderMessage((!filteredRecentOptions.length && !filteredRestOfOptions.length) ? translate('common.noResultsFound') : '');

return [
{
Expand Down Expand Up @@ -95,6 +97,7 @@ function EditReportFieldDropdownPage({fieldName, onSubmit, fieldID, fieldValue,
onChangeText={setSearchValue}
highlightSelectedOptions
isRowMultilineSupported
headerMessage={headerMessage}
/>
</>
)}
Expand Down

0 comments on commit 5dc148c

Please sign in to comment.