Skip to content

Commit

Permalink
feat(DropdownItem): callback with (e, props) onClick (#805)
Browse files Browse the repository at this point in the history
breaking(DropdownItem): callback with (e, props) onClick
  • Loading branch information
levithomason committed Nov 7, 2016
1 parent 77aa062 commit 661c705
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/modules/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default class Dropdown extends Component {
/** Called when a close event happens */
onClose: PropTypes.func,

/** Called when an open event happens */
/** Called when an open event happens */
onOpen: PropTypes.func,

/** Called with the React Synthetic Event and current value on search input change. */
Expand Down Expand Up @@ -513,7 +513,7 @@ export default class Dropdown extends Component {
this.toggle(e)
}

handleItemClick = (e, value) => {
handleItemClick = (e, { value }) => {
debug('handleItemClick()')
debug(value)
const { multiple, name, onAddItem, options } = this.props
Expand Down
6 changes: 3 additions & 3 deletions src/modules/Dropdown/DropdownItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class DropdownItem extends Component {
PropTypes.string,
]),

/** Called on click with (event, value, text). */
/** Called on click with (event, props). */
onClick: PropTypes.func,
}

Expand All @@ -76,9 +76,9 @@ export default class DropdownItem extends Component {
}

handleClick = (e) => {
const { onClick, value } = this.props
const { onClick } = this.props

if (onClick) onClick(e, value)
if (onClick) onClick(e, this.props)
}

render() {
Expand Down
6 changes: 3 additions & 3 deletions test/specs/modules/Dropdown/DropdownItem-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ describe('DropdownItem', () => {
expect(click).to.not.throw()
})

it('is called with (e, value) when clicked', () => {
it('is called with (e, props) when clicked', () => {
const spy = sandbox.spy()

const value = faker.hacker.phrase()
const event = { target: null }
const props = { value }
const props = { value, foo: 'bar' }

shallow(<DropdownItem onClick={spy} {...props} />)
.simulate('click', event)

spy.should.have.been.calledOnce()
spy.should.have.been.calledWithMatch(event, value)
spy.should.have.been.calledWithMatch(event, props)
})
})
})

0 comments on commit 661c705

Please sign in to comment.