Skip to content

Commit aff9acc

Browse files
authored
add loading to results & adjust references display (#56289)
1 parent eed0a10 commit aff9acc

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/search/components/input/AskAIResults.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,8 @@ export function AskAIResults({
481481
></IconButton>
482482
</div>
483483
) : null}
484-
{!aiCouldNotAnswer && references && references.length > 0 ? (
484+
{!aiCouldNotAnswer && !responseLoading && references && references.length > 0 ? (
485485
<>
486-
<ActionList.Divider aria-hidden="true" />
487486
<ActionList className={styles.referencesList} showDividers>
488487
<ActionList.Group>
489488
<ActionList.GroupHeading

src/search/components/input/SearchOverlay.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,11 @@ export function SearchOverlay({
377377
eventGroupId: askAIEventGroupId.current,
378378
})
379379
setSelectedIndex(-1)
380+
setSearchLoading(true)
380381
updateParams({
381382
'search-overlay-ask-ai': 'true',
382383
'search-overlay-input': selectedOption.term,
383384
})
384-
setSearchLoading(true)
385385
setAIQuery(selectedOption.term)
386386
inputRef.current?.focus()
387387
}
@@ -645,6 +645,7 @@ export function SearchOverlay({
645645
listElementsRef,
646646
askAIState,
647647
showSpinner,
648+
searchLoading,
648649
previousSuggestionsListHeight,
649650
)}
650651
</ActionList>
@@ -673,6 +674,7 @@ export function SearchOverlay({
673674
listElementsRef,
674675
askAIState,
675676
showSpinner,
677+
searchLoading,
676678
previousSuggestionsListHeight,
677679
)}
678680
</ActionList>
@@ -883,14 +885,16 @@ function renderSearchGroups(
883885
setAICouldNotAnswer: (value: boolean) => void
884886
},
885887
showSpinner: boolean,
888+
searchLoading: boolean,
886889
previousSuggestionsListHeight: number | string,
887890
) {
888891
const groups = []
889892

890893
let isInAskAIState = askAIState?.isAskAIState && !askAIState.aiSearchError
891894
let isInAskAIStateButNoAnswer = isInAskAIState && askAIState.aiCouldNotAnswer
892895

893-
// already showing spinner when streaming AI response, so don't want to show 2 here
896+
// This spinner is for both the AI search and the general search results.
897+
// We already show a spinner when streaming AI response, so don't want to show 2 here
894898
if (showSpinner && !isInAskAIState) {
895899
groups.push(
896900
<Box
@@ -1005,7 +1009,19 @@ function renderSearchGroups(
10051009
<ActionList.GroupHeading as="h3" tabIndex={-1}>
10061010
{t('search.overlay.general_suggestions_list_heading')}
10071011
</ActionList.GroupHeading>
1008-
{items}
1012+
{searchLoading && isInAskAIState ? (
1013+
<Box
1014+
role="status"
1015+
className={styles.loadingContainer}
1016+
sx={{
1017+
height: `${previousSuggestionsListHeight}px`,
1018+
}}
1019+
>
1020+
<Spinner />
1021+
</Box>
1022+
) : (
1023+
items
1024+
)}
10091025
</ActionList.Group>,
10101026
)
10111027

0 commit comments

Comments
 (0)