[AI Search] minimum change to not persist search params (#55208)
This commit is contained in:
@@ -123,9 +123,7 @@ test('open new search, and select a general search article', async ({ page }) =>
|
||||
await page.keyboard.press('Enter')
|
||||
|
||||
// We should now be on the page for "For Playwright"
|
||||
await expect(page).toHaveURL(
|
||||
/\/get-started\/foo\/for-playwright\?search-overlay-input=serve\+playwright$/,
|
||||
)
|
||||
await expect(page).toHaveURL(/\/get-started\/foo\/for-playwright$/)
|
||||
await expect(page).toHaveTitle(/For Playwright/)
|
||||
})
|
||||
|
||||
|
||||
@@ -44,12 +44,6 @@ export const UnrenderedMarkdownContent = ({
|
||||
if (existingURLParams.get('feature')) {
|
||||
newParams.set('feature', existingURLParams.get('feature') || '')
|
||||
}
|
||||
if (existingURLParams.get('search-overlay-ask-ai')) {
|
||||
newParams.set('search-overlay-ask-ai', existingURLParams.get('search-overlay-ask-ai') || '')
|
||||
}
|
||||
if (existingURLParams.get('search-overlay-input')) {
|
||||
newParams.set('search-overlay-input', existingURLParams.get('search-overlay-input') || '')
|
||||
}
|
||||
// Combine new and existing query parameters
|
||||
if (newParams.toString()) {
|
||||
href = `${href}?${existingAnchorParams}&${newParams.toString()}`
|
||||
|
||||
@@ -332,6 +332,9 @@ export function SearchOverlay({
|
||||
if (searchParams.has('search-overlay-open')) {
|
||||
searchParams.delete('search-overlay-open')
|
||||
}
|
||||
if (searchParams.has('search-overlay-input')) {
|
||||
searchParams.delete('search-overlay-input')
|
||||
}
|
||||
router.push(`${selectedOption.url}?${searchParams.toString()}` || '')
|
||||
onClose()
|
||||
}
|
||||
@@ -373,11 +376,8 @@ export function SearchOverlay({
|
||||
eventGroupId: askAIEventGroupId.current,
|
||||
})
|
||||
setSelectedIndex(-1)
|
||||
const searchParams = new URLSearchParams((router.query as Record<string, string>) || {})
|
||||
if (searchParams.has('search-overlay-open')) {
|
||||
searchParams.delete('search-overlay-open')
|
||||
}
|
||||
window.open(`${url}?${searchParams.toString()}` || '', '_blank')
|
||||
// hardcode the feature to ai_search for now, delete when GA is ready
|
||||
window.open(`${url}?feature=ai_search` || '', '_blank')
|
||||
}
|
||||
|
||||
// Handle keyboard navigation of suggestions
|
||||
|
||||
Reference in New Issue
Block a user