-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[AutoComplete] Fix undesired behaviour with controlled searchText #6621
Conversation
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.
👍 for no using the searchText
state when the component is controlled.
src/AutoComplete/AutoComplete.js
Outdated
this.setState({ | ||
searchText: searchText, | ||
}, () => { | ||
this.props.onUpdateInput(searchText, this.props.dataSource, { |
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.
Shouldn't we always call onUpdateInput
?
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.
You mean why we don't call onUpdateInput
when searchText
is controlled? If so, it's seems logical for me to not call it in this case (because we don't change input actually). If user wants to change searchText
, he will do it in onNewRequest
handler.
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.
Sure but that's a breaking change with the current behavior. Users can use the options argument to filter out that call.
I think that you are right but not introducing a breaking change is even more important.
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.
got your point, done
src/AutoComplete/AutoComplete.js
Outdated
source: 'touchTap', | ||
}); | ||
|
||
this.timerTouchTapCloseId = setTimeout(() => { |
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.
Can we keep that DRY?
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.
done
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.
Aside from my comment, I think that this PR is going in the right direction.
We still use the searchText state in many locations, like in the handleChange
function. But as we plan deep refactorisation for the next
branch, it sounds better to do as little change as possible in order to reduce the risk of fixing that issue.
src/AutoComplete/AutoComplete.js
Outdated
this.setState({ | ||
searchText: searchText, | ||
}, () => { | ||
this.props.onUpdateInput(searchText, this.props.dataSource, { |
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.
Same, can we keep that DRY?
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.
done, sorry for long reply
55b0448
to
3dad6d5
Compare
Thanks. |
this is resolve #6618