-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix/29901: Selected category should be in the list #32902
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ea7e89a
add selected category first
DylanDylann a9bf6d6
add selected category once
DylanDylann 61a83f4
fix lint
DylanDylann 3140d05
merge main
DylanDylann 910e9bf
merge main
DylanDylann 477c3a3
fix lint
DylanDylann 7a914e8
merge main
DylanDylann 7039ed9
fix margin bug
DylanDylann 3abcdfb
fix margin bug
DylanDylann 19891e1
fix margin bug
DylanDylann 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 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 |
---|---|---|
|
@@ -847,31 +847,34 @@ function getCategoryListSections(categories, recentlyUsedCategories, selectedOpt | |
return categorySections; | ||
} | ||
|
||
if (numberOfCategories < CONST.CATEGORY_LIST_THRESHOLD) { | ||
if (!_.isEmpty(selectedOptions)) { | ||
categorySections.push({ | ||
// "All" section when items amount less than the threshold | ||
// "Selected" section | ||
title: '', | ||
shouldShow: false, | ||
indexOffset, | ||
data: getCategoryOptionTree(enabledCategories), | ||
data: getCategoryOptionTree(selectedOptions, true), | ||
}); | ||
|
||
return categorySections; | ||
indexOffset += selectedOptions.length; | ||
} | ||
|
||
if (!_.isEmpty(selectedOptions)) { | ||
const selectedOptionNames = _.map(selectedOptions, (selectedOption) => selectedOption.name); | ||
const filteredCategories = _.filter(enabledCategories, (category) => !_.includes(selectedOptionNames, category.name)); | ||
const numberOfVisibleCategories = selectedOptions.length + filteredCategories.length; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have checked if the |
||
|
||
if (numberOfVisibleCategories < CONST.CATEGORY_LIST_THRESHOLD) { | ||
categorySections.push({ | ||
// "Selected" section | ||
// "All" section when items amount less than the threshold | ||
title: '', | ||
shouldShow: true, | ||
shouldShow: false, | ||
indexOffset, | ||
data: getCategoryOptionTree(selectedOptions, true), | ||
data: getCategoryOptionTree(filteredCategories), | ||
}); | ||
|
||
indexOffset += selectedOptions.length; | ||
return categorySections; | ||
} | ||
|
||
const selectedOptionNames = _.map(selectedOptions, (selectedOption) => selectedOption.name); | ||
const filteredRecentlyUsedCategories = _.chain(recentlyUsedCategories) | ||
.filter((categoryName) => !_.includes(selectedOptionNames, categoryName) && lodashGet(categories, [categoryName, 'enabled'], false)) | ||
.map((categoryName) => ({ | ||
|
@@ -894,8 +897,6 @@ function getCategoryListSections(categories, recentlyUsedCategories, selectedOpt | |
indexOffset += filteredRecentlyUsedCategories.length; | ||
} | ||
|
||
const filteredCategories = _.filter(enabledCategories, (category) => !_.includes(selectedOptionNames, category.name)); | ||
|
||
categorySections.push({ | ||
// "All" section when items amount more than the threshold | ||
title: Localize.translateLocal('common.all'), | ||
|
This file contains 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
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.
ok so true > false change is fine but curious why this empty section header is needed when title is empty.
App/src/components/OptionsList/BaseOptionsList.js
Lines 236 to 238 in 595bf40
Have you found any case this is necessary?
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.
@aimane-chnaif I see that we also do the same thing in here
App/src/libs/OptionsListUtils.js
Lines 824 to 828 in 595bf40
so that I update shouldshow : true > false to make it consistency