-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(List): handler for <List selection/> #1530
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1530 +/- ##
==========================================
- Coverage 99.74% 99.74% -0.01%
==========================================
Files 141 141
Lines 2384 2381 -3
==========================================
- Hits 2378 2375 -3
Misses 6 6
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look great. We just need to add some tests. Looking, there are a few things I'd like to fix with tests in this area, so I'll push those shortly.
I've converted the List/ListItem components into classes. This is due to the click handlers. We don't want to re-create them on every render, so they need to live on the class instance. I then added a couple tests for the click handler. I'm a little torn on the differences between The menu preserves the user's menu item Thoughts? |
Hm. It may be useful to preserve |
_.invoke(predefinedProps, 'onClick', e, itemProps) | ||
_.invoke(this.props, 'onItemClick', e, itemProps) | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated handlers there like in #1428. I also removed index
there, I think we don't really need it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, the Menu only needs it as there is an activeIndex
.
|
||
onClick.should.have.been.calledOnce() | ||
onClick.should.have.been.calledWithMatch(event, callbackData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also updated test, now it tests that item
handler fired too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@levithomason I've rebased with master and performed some updates in handlers and tests. Also added some missing tests for shorthand factories. I think we ready for review 👍
@josie11 Thanks for PR 👍
expect(click).to.not.throw() | ||
}) | ||
|
||
it('is called with (e, { index, ...itemProps }) when clicked', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more index here.
Looks great, made one update to a test description. Will merge tomorrow (3am here)! |
Released in |
To address the enhancement requested in issue #1301.
onItemClick can be passed to List when there are no children; for click handling of list items
<List content={['item1', 'item2', 'item3']} onItemClick={console.log} />
ListItem has click handler for passing list item props.