File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed
src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ export const useSearchQuery = () => {
2424 return useQuery < SearchResponse > ( {
2525 queryKey : [ 'search' , { searchTerm : debouncedSearchTerm } ] ,
2626 queryFn : async ( ) => {
27+ if ( ! debouncedSearchTerm || debouncedSearchTerm . length < 1 ) {
28+ return SearchResponse . parse ( { results : [ ] , totalResults : 0 } )
29+ }
30+
2731 const response = await fetch (
2832 '/docs/_api/v1/search?q=' +
2933 encodeURIComponent ( debouncedSearchTerm )
Original file line number Diff line number Diff line change 11import { SearchOrAskAiButton } from './SearchOrAskAiButton'
22import r2wc from '@r2wc/react-to-web-component'
3+ import { QueryClient , QueryClientProvider } from '@tanstack/react-query'
34import * as React from 'react'
45import { StrictMode } from 'react'
56
67const SearchOrAskAi = ( ) => {
8+ const queryClient = new QueryClient ( )
79 return (
810 < StrictMode >
9- < SearchOrAskAiButton />
11+ < QueryClientProvider client = { queryClient } >
12+ < SearchOrAskAiButton />
13+ </ QueryClientProvider >
1014 </ StrictMode >
1115 )
1216}
Original file line number Diff line number Diff line change @@ -10,18 +10,15 @@ import {
1010 EuiHorizontalRule ,
1111} from '@elastic/eui'
1212import { css } from '@emotion/react'
13- import { QueryClient , QueryClientProvider } from '@tanstack/react-query'
1413import * as React from 'react'
1514
1615export const SearchOrAskAiModal = ( ) => {
1716 const searchTerm = useSearchTerm ( )
1817 const askAiTerm = useAskAiTerm ( )
1918 const { setSearchTerm, submitAskAiTerm } = useSearchActions ( )
2019
21- const queryClient = new QueryClient ( )
22-
2320 return (
24- < QueryClientProvider client = { queryClient } >
21+ < >
2522 < EuiFieldSearch
2623 fullWidth
2724 placeholder = "Search the docs or ask Elastic Docs AI Assistant"
@@ -59,6 +56,6 @@ export const SearchOrAskAiModal = () => {
5956 This feature is in beta. Got feedback? We'd love to hear it!
6057 </ EuiText >
6158 </ div >
62- </ QueryClientProvider >
59+ </ >
6360 )
6461}
You can’t perform that action at this time.
0 commit comments