-
Notifications
You must be signed in to change notification settings - Fork 933
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(pickState): only pick relevant state #183
Conversation
Make `toggleMenu` and friends more user-friendly by only picking out state that is relevant to downshift, allowing users to use them as event event handlers. See #182.
Codecov Report
@@ Coverage Diff @@
## master #183 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 4 4
Lines 267 277 +10
Branches 64 65 +1
=====================================
+ Hits 267 277 +10
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.
Looks super! Just one idea.
@@ -154,6 +155,7 @@ class Downshift extends Component { | |||
highlightedIndex = this.props.defaultHighlightedIndex, | |||
otherStateToSet = {}, | |||
) => { | |||
otherStateToSet = pickState(otherStateToSet) |
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.
Actually, I think this is the only place we really need this function called because all the other code paths lead here. Try removing the other changes and see if this works. I think it will.
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 just tried this, and it didn't work for me. I also tried to move this further down into internalSetState
, and that didn't remove the warnings either.
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.
Looks perfect! thanks!
Make
toggleMenu
and friends more user-friendly by only picking outstate that is relevant to downshift, allowing users to use them as event
event handlers. See #182.
What: Make
toggleMenu
and friends more user-friendly.Why: See #182.
How: Add
pickState
and call it whenever we are about to spreadotherStateToSet
intointernalSetState
Checklist:
Additional comments:
When I initially pulled the most recent from master,
npm run validate
failed.I investigated a bit. Only the
build-and-test
task is failing.lint
,test:cover
, andtest:ts
succeed. I decided to ignore it while developing because I could still run the other test tasks, thinking it could just be a problem with my machine. Please let me know if we should address this first.I wanted to add direct tests on
toggleMenu
and others todownshift.misc.js
(in addition to addingutils.pick-state.js
), but there wasn't a way to test what object was being passed tointernalSetState
. No matter what the internal state is, we always pass the correct keys torender
(https://github.com/paypal/downshift/blob/master/src/downshift.js#L336). So, with the current test setup, I couldn't find a way to see what the internals were. I decided it was OK, thinking the new test was sufficient, but let me know if you think otherwise.Locally, I added a new story to test the changes. It didn't seem appropriate to include it in the commit, but let me know if you think otherwise.