-
Notifications
You must be signed in to change notification settings - Fork 933
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new prop 'stateReducer' #320
Add new prop 'stateReducer' #320
Conversation
At now, you could provide your own function that could modify the state that will be set.
Codecov Report
@@ Coverage Diff @@
## master #320 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 4 4
Lines 327 329 +2
Branches 82 82
=====================================
+ Hits 327 329 +2
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.
This is an awesome start! Let's get the docs and tests done and this is totally mergible. I'm really happy with it actually! It feels like a new really useful pattern that I'll want to write a blog about and make/update a few examples with :D
README.md
Outdated
origin of the change which has references in `Downshift.stateChangeTypes` | ||
as in [`onStateChange`](#onstatechange). | ||
|
||
This is a pure function. You _might_ think of it as a simple reducer! |
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.
This is where I decided to switch the function signature to accept state first. I think some folks will get giddy about this 馃槈
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.
Right. State first its better; like simple reducer.
README.md
Outdated
// selects an item with the keyboard | ||
switch (stateToSet.type) { | ||
case Downshift.stateChangeTypes.keyDownEnter: | ||
case Downshift.stateChangeTypes.clickItem: |
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.
As I was copying your test over for the example I realized that if the user selected an item with the mouse it would still close and then realized we didn't have a type
for that situation, so I added one in this PR 馃憤
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 know, I planned to add { type: Downshift.stateChangeTypes.itemClick }
here after that PR 馃槄.
(You already did it, COOL!)
@NoTruth, could you give this a look over and make sure you like it? I'll merge it when you give me the 馃憤 |
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 like it 馃憣! Thanks!
README.md
Outdated
// selects an item with the keyboard | ||
switch (stateToSet.type) { | ||
case Downshift.stateChangeTypes.keyDownEnter: | ||
case Downshift.stateChangeTypes.clickItem: |
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 know, I planned to add { type: Downshift.stateChangeTypes.itemClick }
here after that PR 馃槄.
(You already did it, COOL!)
Sweet. I'll merge this myself in an hour or two... I just tweeted about it and I'm sure we'll get some interesting feedback. I think maybe the prop name could be improved... |
That's a good idea thank you! |
Someone suggested the name Though I actually kind of like |
|
What about |
Yes, probably better |
Cool! I think I want to change it to |
I can forget somewhere to replace wording) 褋ould You do it? |
Sure 馃憤 |
This looks awesome. Great work @NoTruth @kentcdodds |
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.
cool, thanks
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.
This is ready!
Awesome, thanks! |
Thank you @NoTruth! |
* Add new prop 'modifyStateChange' At now, you could provide your own function that could modify the state that will be set. * Add simple test for modifyStateChange prop * Update README.md * Update downshift.js * Update downshift.props.js * Update downshift.js * Update README.md * rename to stateReducer * cleanup readme wording * lock version * improve docs * typo fix * remove tics
What:
At now, you could provide your own function that could modify the state that will be set. You could check the type property of stateToSet against this list to know whether you want to modify how the state is changed. @kentcdodds
Why:
Chain of ideas: #319.
How:
Checklist:
Tests and documentation I can add tomorrow(if nobody else wants).
(modify my wording, if I stumbled somewhere 馃榿 )