Skip to content

Commit 553df48

Browse files
vageeshblevithomason
authored andcommitted
fix(dropdown): clear value when dropdown is blurred (#1046)
fixes #1019
1 parent 166878e commit 553df48

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/modules/Dropdown/Dropdown.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ export default class Dropdown extends Component {
654654
if (this.isMouseDown) return
655655
if (onBlur) onBlur(e, this.props)
656656
if (selectOnBlur && !multiple) this.selectHighlightedItem(e)
657-
this.setState({ focus: false })
657+
this.setState({ focus: false, searchQuery: '' })
658658
}
659659

660660
handleSearchChange = (e) => {

test/specs/modules/Dropdown/Dropdown-test.js

+7
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ describe('Dropdown Component', () => {
187187
.should.have.state('focus', false)
188188
})
189189

190+
it('sets searchQuery state to empty', () => {
191+
wrapperShallow(<Dropdown />)
192+
.setState({ searchQuery: 'foo' })
193+
.simulate('blur')
194+
.should.have.state('searchQuery', '')
195+
})
196+
190197
it('does not call onBlur when the mouse is down', () => {
191198
const spy = sandbox.spy()
192199

0 commit comments

Comments
 (0)