-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix tagList highlight #31652
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 tagList highlight #31652
Changes from all commits
d0dee28
0c9edf6
c64984e
07e6716
07fd587
53213f3
4ddac94
850d8f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,25 +37,30 @@ function TagPicker({selectedTag, tag, policyTags, policyRecentlyUsedTags, onSubm | |
| ]; | ||
| }, [selectedTag]); | ||
|
|
||
| const enabledTags = useMemo(() => { | ||
| const sortedTagList = _.chain(policyTagList) | ||
| .values() | ||
| .sortBy((policyTag) => policyTag.name) | ||
| .value(); | ||
|
|
||
| if (!shouldShowDisabledAndSelectedOption) { | ||
| return sortedTagList; | ||
| } | ||
|
Comment on lines
+46
to
+48
Contributor
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. Actually I don't see the need of this early return.
Contributor
Author
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. I'm not too sure either. The name suggests that we display disabled tags, but I'm not sure that that's happening
Contributor
Author
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. @tienifr @robertKozik could you check this logic? It seems like we'd want to return the |
||
| const selectedNames = _.map(selectedOptions, (s) => s.name); | ||
| return _.chain(sortedTagList) | ||
| .filter((policyTag) => policyTag.enabled || selectedNames.includes(policyTag.name)) | ||
| .value(); | ||
| }, [selectedOptions, policyTagList, shouldShowDisabledAndSelectedOption]); | ||
|
|
||
| const initialFocusedIndex = useMemo(() => { | ||
| if (isTagsCountBelowThreshold && selectedOptions.length > 0) { | ||
| return _.chain(policyTagList) | ||
| .values() | ||
|
luacmartins marked this conversation as resolved.
|
||
| return _.chain(enabledTags) | ||
|
luacmartins marked this conversation as resolved.
|
||
| .findIndex((policyTag) => policyTag.name === selectedOptions[0].name, true) | ||
| .value(); | ||
| } | ||
|
|
||
| return 0; | ||
| }, [policyTagList, selectedOptions, isTagsCountBelowThreshold]); | ||
|
|
||
| const enabledTags = useMemo(() => { | ||
| if (!shouldShowDisabledAndSelectedOption) { | ||
| return policyTagList; | ||
| } | ||
| const selectedNames = _.map(selectedOptions, (s) => s.name); | ||
| const tags = [...selectedOptions, ..._.filter(policyTagList, (policyTag) => policyTag.enabled && !selectedNames.includes(policyTag.name))]; | ||
| return tags; | ||
| }, [selectedOptions, policyTagList, shouldShowDisabledAndSelectedOption]); | ||
| }, [enabledTags, selectedOptions, isTagsCountBelowThreshold]); | ||
|
|
||
| const sections = useMemo( | ||
| () => OptionsListUtils.getFilteredOptions({}, {}, [], searchValue, selectedOptions, [], false, false, false, {}, [], true, enabledTags, policyRecentlyUsedTagsList, false).tagOptions, | ||
|
|
||
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.
Let's add
policyTag.enabledfilter logic here as we don't show disabled tags in any caseAs you see, wrong index after I disable 2nd tag, though not visually noticeable
Screen.Recording.2023-11-22.at.6.01.51.AM.mov