Skip to content

Commit a016c44

Browse files
committed
Improve search result merging and dropdown display
Refines logic in SearchForm to only show account results from slow search if no specific entity is found in fast search. Updates SearchResultDropdown to compare block IDs case-insensitively and only show loading spinner when account results are present.
1 parent 32e6cfb commit a016c44

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

packages/app-explorer/src/systems/Core/components/Search/SearchForm.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,31 @@ export function SearchForm({ className, autoFocus }: SearchFormProps) {
5757
const slowResponse = await ApiService.searchSlow(query).catch(() => null);
5858

5959
if (slowResponse) {
60-
// Merge fast and slow results
60+
// Only add account from slow if fast didn't find a specific entity
61+
// Account is a fallback result, not a primary result
62+
const hasSpecificResult =
63+
fastResponse?.block ||
64+
fastResponse?.contract ||
65+
fastResponse?.transaction ||
66+
fastResponse?.asset ||
67+
fastResponse?.predicate;
68+
6169
let merged: GQLSearchResult | null = null;
6270

63-
if (fastResponse) {
64-
// If we had fast results, merge with slow
65-
merged = {
66-
...fastResponse,
67-
...slowResponse,
68-
};
71+
if (hasSpecificResult) {
72+
// Keep fast results as-is, don't add account
73+
merged = fastResponse;
6974
} else if (slowResponse.account) {
70-
// If slow found account transactions, update the account with transactions
75+
// Only show account from slow if fast found nothing specific
7176
merged = {
7277
account: {
7378
...slowResponse.account,
7479
__typename: 'SearchAccount',
7580
},
7681
} as GQLSearchResult;
7782
} else {
78-
// Keep the empty account we showed earlier, or merge slow results
79-
merged = slowResponse;
83+
// No specific results and no account with transactions
84+
merged = fastResponse; // Could be null or undefined
8085
}
8186

8287
setResults(merged || undefined);

packages/app-explorer/src/systems/Core/components/Search/SearchResultDropdown/SearchResultDropdown.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ export const SearchResultDropdown = forwardRef<
142142
)}
143143
{searchResult?.block && (
144144
<>
145-
{searchResult.block.id === searchValue && (
145+
{searchResult.block.id?.toLowerCase() ===
146+
searchValue?.toLowerCase() && (
146147
<>
147148
<Dropdown.Label className={classes.dropdownLabel()}>
148149
Block Hash
@@ -250,7 +251,7 @@ export const SearchResultDropdown = forwardRef<
250251
</Dropdown.Item>
251252
</>
252253
)}
253-
{loadingMore && (
254+
{loadingMore && searchResult?.account && (
254255
<div className={classes.loadingContainer()}>
255256
<Spinner
256257
size={16}

0 commit comments

Comments
 (0)