fix(command-palette): highlighting after search mode#1672
fix(command-palette): highlighting after search mode#1672d-rita merged 5 commits intofeature-command-palettefrom
Conversation
|
🚀 Deployed on https://pr-1672--dhis2-ui.netlify.app |
3762e33 to
de53c30
Compare
ca9c5e1 to
ea7a9f9
Compare
amcgee
left a comment
There was a problem hiding this comment.
LGTM! Left one minor comment
| const activeItems = useMemo(() => { | ||
| if (currentView === HOME_VIEW) { | ||
| return activeSection === ACTIONS_SECTION ? actionsArray : itemsArray | ||
| return filter || activeSection === GRID_SECTION | ||
| ? itemsArray | ||
| : actionsArray | ||
| } else { | ||
| return filter ? itemsArray : actionsArray.concat(itemsArray) | ||
| } | ||
| }, [filter, itemsArray, actionsArray, currentView, activeSection]) |
There was a problem hiding this comment.
(minor) I think this logic could be cleaned up a bit so it's easier to read. For example, instead of having multiple ternary operators with the filter condition, it should be possible to just have a single if statement at the beginning. And then the remaining ternary could just be a nested if to make it a little easier to read. Something like this, maybe:
const activeItems = useMemo(() => {
if (filter) {
return itemsArray;
}
if (currentView === HOME_VIEW) {
if (activeSection === GRID_SECTION) {
return itemsArray
} else {
return actionsArray
}
} else {
return actionsArray.concat(itemsArray)
}
}, [filter, itemsArray, actionsArray, currentView, activeSection])Another option would be to combine all branches which yield itemsArray in a single if statement:
const activeItems = useMemo(() => {
if (filter || (currentView === HOME_VIEW && activeSection === GRID_SECTION)) {
return itemsArray;
}
if (currentView === HOME_VIEW) {
return actionsArray
} else {
return actionsArray.concat(itemsArray)
}
}, [filter, itemsArray, actionsArray, currentView, activeSection])There are likely other ways to make this a bit more readable, especially by thinking about which variables are needed and how they're named, but regardless it will help to clean up the logic in this memoized callback a bit.
|



Fixes LIBS-756
Description
This PR fixes some highlighting issues after the search filter has been cleared.
back actionChecklist
Screenshots
Before:
list.view.-.before.mov
After:
after.-.list.view.mov