Skip to content

Commit

Permalink
fix(Dropdown): fix crash when setting defaultOpen on a search dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
fracmak committed Dec 8, 2016
1 parent 5a1b82d commit d0e6f43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/modules/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,13 @@ export default class Dropdown extends Component {
componentWillMount() {
if (super.componentWillMount) super.componentWillMount()
debug('componentWillMount()')
const { open, value } = this.state
const { value } = this.state

this.setValue(value)
}

componentDidMount() {
const { open } = this.state
if (open) this.open()
}

Expand Down
4 changes: 4 additions & 0 deletions test/specs/modules/Dropdown/Dropdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,10 @@ describe('Dropdown Component', () => {
wrapperShallow(<Dropdown options={options} selection defaultOpen />)
dropdownMenuIsOpen()
})
it('defaultOpen opens the menu on search dropdowns', () => {
wrapperShallow(<Dropdown search options={options} selection defaultOpen />)
dropdownMenuIsOpen()
})
it('defaultOpen closes the menu when false', () => {
wrapperShallow(<Dropdown options={options} selection defaultOpen={false} />)
dropdownMenuIsClosed()
Expand Down

0 comments on commit d0e6f43

Please sign in to comment.