Skip to content

Commit

Permalink
fix: selected sub-category not show in one line format
Browse files Browse the repository at this point in the history
  • Loading branch information
gijoe0295 committed Mar 14, 2024
1 parent b7a230e commit f905340
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,32 +1000,32 @@ function getCategoryListSections(
return categorySections;
}

const selectedOptionNames = selectedOptions.map((selectedOption) => selectedOption.name);
const enabledAndSelectedCategories = [...selectedOptions, ...sortedCategories.filter((category) => category.enabled && !selectedOptionNames.includes(category.name))];
const numberOfVisibleCategories = enabledAndSelectedCategories.length;

if (numberOfVisibleCategories < CONST.CATEGORY_LIST_THRESHOLD) {
if (selectedOptions.length > 0) {
categorySections.push({
// "All" section when items amount less than the threshold
// "Selected" section
title: '',
shouldShow: false,
indexOffset,
data: getCategoryOptionTree(enabledAndSelectedCategories),
data: getCategoryOptionTree(selectedOptions, true),
});

return categorySections;
indexOffset += selectedOptions.length;
}

if (selectedOptions.length > 0) {
const selectedOptionNames = selectedOptions.map((selectedOption) => selectedOption.name);
const enabledWithoutSelectedCategories = sortedCategories.filter((category) => category.enabled && !selectedOptionNames.includes(category.name));
const numberOfVisibleCategories = enabledWithoutSelectedCategories.length + selectedOptions.length;

if (numberOfVisibleCategories < CONST.CATEGORY_LIST_THRESHOLD) {
categorySections.push({
// "Selected" section
// "All" section when items amount less than the threshold
title: '',
shouldShow: false,
indexOffset,
data: getCategoryOptionTree(selectedOptions, true),
data: getCategoryOptionTree(enabledWithoutSelectedCategories),
});

indexOffset += selectedOptions.length;
return categorySections;
}

const filteredRecentlyUsedCategories = recentlyUsedCategories
Expand Down

0 comments on commit f905340

Please sign in to comment.