Skip to content

Commit

Permalink
feat(searchbar): if query is set, use it as default value
Browse files Browse the repository at this point in the history
  • Loading branch information
joemcelroy committed Dec 13, 2020
1 parent 9f474ff commit b7543aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -45,4 +45,14 @@ describe('SearchBar', () => {
sortBy: null
})
})

it('api has a query in state', async () => {
const mockApi: SearchkitClient = SearchkitClient as any
const searchCall = jest.fn()
mockApi.setCallbackFn(searchCall)
mockApi.setQuery('heat')
render(<SearchBar loading={false} />)
expect(screen.getByLabelText('Search')).toBeVisible()
expect(screen.getByLabelText('Search')).toHaveDisplayValue('heat')
})
})
2 changes: 1 addition & 1 deletion packages/searchkit-elastic-ui/src/SearchBar/index.tsx
Expand Up @@ -4,7 +4,7 @@ import React, { useState } from 'react'

export const SearchBar = ({ loading }) => {
const api = useSearchkit()
const [value, setValue] = useState('')
const [value, setValue] = useState(api.getQuery())

return (
<EuiFieldSearch
Expand Down

0 comments on commit b7543aa

Please sign in to comment.