Skip to content
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

Merged
merged 2 commits into from
Feb 5, 2025
Merged

PORTALS-3382 #1554

merged 2 commits into from
Feb 5, 2025

Conversation

jay-hodgson
Copy link
Member

No description provided.

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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this too dense?

Copy link
Collaborator

@nickgros nickgros Feb 5, 2025

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

@jay-hodgson
Copy link
Member Author

Adds a loading UI (while the initial queries are executed), and navigates to the tab with the max count once all counts are set.
image

@jay-hodgson jay-hodgson requested a review from nickgros February 5, 2025 18:43
Comment on lines +118 to +120
{selectedTabIndex != undefined && (
<PortalSearchTabs tabConfig={searchPageTabsState} />
)}
Copy link
Collaborator

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

Copy link
Collaborator

@nickgros nickgros left a 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

@jay-hodgson jay-hodgson merged commit 6e286a2 into Sage-Bionetworks:main Feb 5, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants