Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking(DropdownItem): callback with (e, props) onClick #805

Merged
merged 2 commits into from
Nov 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
})
})