Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.
Open
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
3 changes: 2 additions & 1 deletion lib/Autocomplete.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ class Autocomplete extends React.Component {
}

isOpen() {
return 'open' in this.props ? this.props.open : this.state.isOpen
if ('open' in this.props && this.props.open !== undefined && this.props.open !== null) return this.props.open
else return this.state.isOpen
}

render() {
Expand Down
8 changes: 7 additions & 1 deletion lib/__tests__/Autocomplete-test.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('Autocomplete acceptance tests', () => {
expect(tree.state('highlightedIndex')).toEqual(0)
})

it('should display menu based on `props.open` when provided', () => {
it('should display menu based on `props.open` when provided with bool', () => {
const tree = mount(AutocompleteComponentJSX({}))
expect(tree.state('isOpen')).toBe(false)
expect(tree.find('> div').length).toBe(0)
Expand All @@ -159,6 +159,12 @@ describe('Autocomplete acceptance tests', () => {
expect(tree.find('> div').length).toBe(0)
tree.setProps({ open: true })
expect(tree.find('> div').length).toBe(1)
tree.setProps({ open: null })
tree.setState({ isOpen: false })
expect(tree.find('> div').length).toBe(0)
tree.setProps({ open: undefined })
tree.setState({ isOpen: false })
expect(tree.find('> div').length).toBe(0)
})

it('should set menu positions on initial render if the menu is visible', () => {
Expand Down