diff --git a/package-lock.json b/package-lock.json index 4445e04e5e3f..a7414fbdbdd9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15510,9 +15510,9 @@ "license": "MIT" }, "node_modules/vite": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/vite/-/vite-6.2.3.tgz", - "integrity": "sha512-IzwM54g4y9JA/xAeBPNaDXiBF8Jsgl3VBQ2YQ/wOY6fyW3xMdSoltIV3Bo59DErdqdE6RxUfv8W69DvUorE4Eg==", + "version": "6.2.4", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.2.4.tgz", + "integrity": "sha512-veHMSew8CcRzhL5o8ONjy8gkfmFJAd5Ac16oxBUjlwgX3Gq2Wqr+qNC3TjPIpy7TPV/KporLga5GT9HqdrCizw==", "dev": true, "dependencies": { "esbuild": "^0.25.0", diff --git a/src/fixtures/tests/playwright-rendering.spec.ts b/src/fixtures/tests/playwright-rendering.spec.ts index 599be99e7d75..eea490203b49 100644 --- a/src/fixtures/tests/playwright-rendering.spec.ts +++ b/src/fixtures/tests/playwright-rendering.spec.ts @@ -86,8 +86,8 @@ test('open new search, and perform a general search', async ({ page }) => { // NOTE: In the UI we wait for results to load before allowing "enter", because we don't want // to allow an unnecessary request when there are no search results. Easier to wait 1 second await page.waitForTimeout(1000) - // Press enter to perform general search - await page.keyboard.press('Enter') + // Scroll down to "View all results" then press enter + await page.getByText('View more results').click() await expect(page).toHaveURL( /\/search\?search-overlay-input=serve\+playwright&query=serve\+playwright/, diff --git a/src/search/components/helpers/execute-search-actions.ts b/src/search/components/helpers/execute-search-actions.ts index 6d44e601efe9..24809ef0ca37 100644 --- a/src/search/components/helpers/execute-search-actions.ts +++ b/src/search/components/helpers/execute-search-actions.ts @@ -42,7 +42,7 @@ export function executeGeneralSearch( params.delete('search-overlay-open') } asPath += `?${params}` - router.push(asPath) + router.push(asPath, undefined, { shallow: false }) } export async function executeAISearch( diff --git a/src/search/components/input/SearchOverlay.tsx b/src/search/components/input/SearchOverlay.tsx index 4f05d07c31af..1300c2759868 100644 --- a/src/search/components/input/SearchOverlay.tsx +++ b/src/search/components/input/SearchOverlay.tsx @@ -435,19 +435,15 @@ export function SearchOverlay({ let pressedGroupId = searchEventGroupId let pressedOnContext = '' + // When enter is pressed and no option is manually selected (-1), perform an AI search with the user input if (selectedIndex === -1) { if (isAskAIState) { pressedOnContext = AI_SEARCH_CONTEXT pressedGroupKey = ASK_AI_EVENT_GROUP pressedGroupId = askAIEventGroupId - // When we are in the Ask AI state, we want to ask another AI Search query - aiSearchOptionOnSelect({ term: urlSearchInputQuery } as AutocompleteSearchHit) - } else if (generalSearchResults.length > 0) { - pressedOnContext = GENERAL_SEARCH_CONTEXT - // Nothing manually selected, so general search the typed suggestion - performGeneralSearch() } - return sendKeyboardEvent(event.key, pressedOnContext, pressedGroupId, pressedGroupKey) + sendKeyboardEvent(event.key, pressedOnContext, pressedGroupId, pressedGroupKey) + aiSearchOptionOnSelect({ term: urlSearchInputQuery } as AutocompleteSearchHit) } if ( @@ -456,28 +452,30 @@ export function SearchOverlay({ selectedIndex < combinedOptions.length ) { const selectedItem = combinedOptions[selectedIndex] + let action = () => {} // Execute the action after we send the event if (selectedItem.group === 'general') { if ( (selectedItem.option as GeneralSearchHitWithOptions).isViewAllResults || (selectedItem.option as GeneralSearchHitWithOptions).isSearchDocsOption ) { pressedOnContext = 'view-all' - performGeneralSearch() + action = performGeneralSearch } else { pressedOnContext = 'general-option' - generalSearchResultOnSelect(selectedItem.option as GeneralSearchHit) + action = () => generalSearchResultOnSelect(selectedItem.option as GeneralSearchHit) } } else if (selectedItem.group === 'ai') { pressedOnContext = 'ai-option' - aiSearchOptionOnSelect(selectedItem.option as AutocompleteSearchHit) + action = () => aiSearchOptionOnSelect(selectedItem.option as AutocompleteSearchHit) } else if (selectedItem.group === 'reference') { // On a reference select, we are in the Ask AI State / Screen pressedGroupKey = ASK_AI_EVENT_GROUP pressedGroupId = askAIEventGroupId pressedOnContext = 'reference-option' - referenceOnSelect(selectedItem.url || '') + action = () => referenceOnSelect(selectedItem.url || '') } sendKeyboardEvent(event.key, pressedOnContext, pressedGroupId, pressedGroupKey) + return action() } } else if (event.key === 'Escape') { event.preventDefault()