Skip to content

Commit

Permalink
fix(Dropdown): use placeholder as default text (#3586)
Browse files Browse the repository at this point in the history
* Fix #3581

* Update Dropdown.js

* Update Dropdown-test.js
  • Loading branch information
eyas2014 authored and layershifter committed Jul 7, 2019
1 parent f8e894c commit 087593c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/modules/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -1193,9 +1193,8 @@ export default class Dropdown extends Component {
search && searchQuery && 'filtered',
)
let _text = placeholder
if (searchQuery) {
_text = null
} else if (text) {

if (text) {
_text = text
} else if (open && !multiple) {
_text = _.get(this.getSelectedItem(), 'text')
Expand Down
7 changes: 7 additions & 0 deletions test/specs/modules/Dropdown/Dropdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,13 @@ describe('Dropdown', () => {
})

describe('text', () => {
it('defaults to "placeholder"', () => {
const placeholder = faker.hacker.phrase()

wrapperMount(<Dropdown options={options} placeholder={placeholder} />)
.find('div.text')
.should.contain.text(placeholder)
})
it('sets the display text', () => {
const text = faker.hacker.phrase()

Expand Down

0 comments on commit 087593c

Please sign in to comment.