Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-storefront",
"version": "8.3.4",
"version": "8.4.0",
"description": "Build and deploy e-commerce progressive web apps (PWAs) in record time.",
"module": "./index.js",
"license": "Apache-2.0",
Expand Down
14 changes: 13 additions & 1 deletion src/search/SearchPopover.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ export const styles = theme => ({

const useStyles = makeStyles(styles, { name: 'RSFSearchPopover' })

export default function SearchPopover({ classes, children, open, onClose, anchor, setQuery }) {
/**
* Displays search results in a popover. Additional props are spread to the underlying Material UI Popover element.
*/
export default function SearchPopover({
classes,
children,
open,
onClose,
anchor,
setQuery,
...others
}) {
classes = useStyles({ classes })

const handleNavigation = () => {
Expand Down Expand Up @@ -58,6 +69,7 @@ export default function SearchPopover({ classes, children, open, onClose, anchor
square: true,
className: classes.popoverPaper,
}}
{...others}
>
{children}
</Popover>
Expand Down
19 changes: 18 additions & 1 deletion test/search/SearchPopover.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useRef, useEffect, useState } from 'react'
import { mount } from 'enzyme'
import SearchPopover from 'react-storefront/search/SearchPopover'
import { Popover } from '@material-ui/core'
import { navigate } from '../mocks/mockRouter'

describe('SearchPopover', () => {
Expand Down Expand Up @@ -38,7 +39,7 @@ describe('SearchPopover', () => {
})

it('should work when useQuery and onClose not provided', () => {
wrapper = mount(<TestComponent onClose={null} useQuery={null} />)
wrapper = mount(<TestComponent onClose={null} />)

navigate('/foo')
expect(wrapper.find('#test')).toExist()
Expand All @@ -59,4 +60,20 @@ describe('SearchPopover', () => {
expect(setQueryMock).toHaveBeenCalledWith('')
expect(blurMock).toHaveBeenCalled()
})

it('should spread additional props to the underlying Popover element', () => {
wrapper = mount(
<TestComponent
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
}}
/>,
)

expect(wrapper.find(Popover).props().anchorOrigin).toEqual({
vertical: 'bottom',
horizontal: 'right',
})
})
})