-
Notifications
You must be signed in to change notification settings - Fork 402
Adding clear btn callback #630
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
Conversation
adding callback on clear
Codecov Report
@@ Coverage Diff @@
## master #630 +/- ##
=======================================
Coverage 99.84% 99.84%
=======================================
Files 44 44
Lines 661 663 +2
Branches 134 135 +1
=======================================
+ Hits 660 662 +2
Misses 1 1
Continue to review full report at Codecov.
|
1 similar comment
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.
Hey @anonymous-ME, thanks for submitting this PR. The issue you're trying to solve with this change is actually a bit more complicated than it first appears. onInputChange
also passes the change event as the second argument, but that event doesn't actually happen, since the value changes in response to a click on a different element.
|
||
export function clearTypeahead(state: TypeaheadState, props: Props) { | ||
if (typeof props.onInputChange === "function") { | ||
props.onInputChange(""); |
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 noted, onInputChange
passes the change event as the second argument. It also doesn't seem like a good idea to trigger a callback during a state change. That should happen after the state change is complete.
Oh, and if you'd like to continue pursuing this change, some tests would be great :) |
Hi @ericgio, what solution would you suggest in this case? |
Should we add a callback for onClear instead? |
I think the solution is that the event needs to be manually triggered by the clear callback, which would then trigger |
Hi @ericgio, I'm thinking of doing something like this to simulate onChange for TypeaheadManager.
But not sure how to get TypeaheadManager element reference inside of clearTypeahead callback. |
Thanks for having a look at this! The callback was added in v5.2 |
What issue does this pull request resolve?
onInputChange not called when input cleared. Fix for this issue #594
What changes did you make?
added the callBack
Is there anything that requires more attention while reviewing?
nope