diff --git a/lib/Autocomplete.js b/lib/Autocomplete.js old mode 100644 new mode 100755 index 202389d8..49aad59d --- a/lib/Autocomplete.js +++ b/lib/Autocomplete.js @@ -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() { diff --git a/lib/__tests__/Autocomplete-test.js b/lib/__tests__/Autocomplete-test.js old mode 100644 new mode 100755 index 7ad9f759..f0611fa3 --- a/lib/__tests__/Autocomplete-test.js +++ b/lib/__tests__/Autocomplete-test.js @@ -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) @@ -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', () => {