-
Notifications
You must be signed in to change notification settings - Fork 24
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
PORTALS-3382 #1554
PORTALS-3382 #1554
Conversation
if (selectedTabIndex == undefined && allCountsSet) { | ||
// navigate to the tab that has the highest count | ||
const maxCountTab = searchPageTabs.reduce((max, tab) => | ||
max === null || tab.count! > max.count! ? tab : max, |
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.
Is this too dense?
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.
I think it's ok. I might suggest splitting the null case from the comparison with the accumulator. The tricky thing about this statement is trying to remember order of operations between a ternary, ||
, >
, and ===
.
That said, I don't know that you need a null check here. The initial value will be searchPageTabs[0]
, so max
should never be null
.
So I'd either separate the null check into its own statement and specify a null
initial value or remove it altogether
{selectedTabIndex != undefined && ( | ||
<PortalSearchTabs tabConfig={searchPageTabsState} /> | ||
)} |
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.
Ah, so you effectively won't even show the tabs until you have a query. This order of interactions is making more sense to me
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.
Looks good but you may want to refactor that reducer
No description provided.