Skip to content

Commit

Permalink
fix(Dropdown): closeOnBlur={false} does not work (#1998)
Browse files Browse the repository at this point in the history
fix(Dropdown): remove event listener if closeOnBlur={false}
test(Dropdown): add a test for closeOnBlur={false}

fixes #1995
  • Loading branch information
lottamus authored and levithomason committed Aug 27, 2017
1 parent 621ce08 commit b123a10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/modules/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,8 @@ export default class Dropdown extends Component {
debug('closeOnDocumentClick()')
debug(e)

if (!this.props.closeOnBlur) return

// If event happened in the dropdown, ignore it
if (this.ref && _.isFunction(this.ref.contains) && this.ref.contains(e.target)) return

Expand Down
9 changes: 9 additions & 0 deletions test/specs/modules/Dropdown/Dropdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ describe('Dropdown', () => {
dropdownMenuIsClosed()
})

it('does not close on blur with closeOnBlur set to false', () => {
wrapperMount(<Dropdown options={options} closeOnBlur={false} />)
.simulate('click')

dropdownMenuIsOpen()
wrapper.simulate('blur')
dropdownMenuIsOpen()
})

it('blurs the Dropdown node on close', () => {
wrapperMount(<Dropdown options={options} selection defaultOpen />)

Expand Down

0 comments on commit b123a10

Please sign in to comment.