Skip to content

Commit

Permalink
Merge pull request #28091 from situchan/fix-28079
Browse files Browse the repository at this point in the history
fix crash on category picker
  • Loading branch information
tgolen authored Sep 24, 2023
2 parents 4ea4a55 + f22ac9f commit bc588b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/CategoryPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ function CategoryPicker({selectedCategory, policyCategories, policyRecentlyUsedC
let categoryInitialFocusedIndex = 0;

if (!_.isEmpty(searchValue) || isCategoriesCountBelowThreshold) {
const index = _.findIndex(lodashGet(sections, '[0].data', []), (category) => category.searchText === iou.category);
const index = _.findIndex(lodashGet(sections, '[0].data', []), (category) => category.searchText === selectedCategory);

categoryInitialFocusedIndex = index === -1 ? 0 : index;
}

return categoryInitialFocusedIndex;
}, [iou.category, searchValue, isCategoriesCountBelowThreshold, sections]);
}, [selectedCategory, searchValue, isCategoriesCountBelowThreshold, sections]);

const headerMessage = OptionsListUtils.getHeaderMessage(lodashGet(sections, '[0].data.length', 0) > 0, false, searchValue);
const shouldShowTextInput = !isCategoriesCountBelowThreshold;
Expand Down

0 comments on commit bc588b4

Please sign in to comment.