Skip to content
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

onSelectResetsInput regression fixed #2215

Merged
merged 4 commits into from Dec 14, 2017
Merged

Conversation

dehamilton
Copy link
Contributor

Recent changes to componentWillReceiveProps prevented the input from retaining values even if onSelectResetsInput was false. This PR resolves that regression and adds tests around onSelectResetsInput, which I didn't notice anywhere. Also updated package.json to use cross-env for all scripts.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.75% when pulling 2c2630e on dehamilton:master into 700b79a on JedWatson:master.

Copy link
Contributor

@yuri-sakharov yuri-sakharov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Good catch and please take a look on my comments.

@@ -2129,6 +2129,66 @@ describe('Select', () => {

});

describe('with multi=true and onSelectResetsInput=false', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more accurately describe('with multi=true and different onSelectResetsInput', () => {

@@ -2129,6 +2129,66 @@ describe('Select', () => {

});

describe('with multi=true and onSelectResetsInput=false', () => {
it('should have retained inputValue after accepting selection', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it('should have retained inputValue after accepting selection if onSelectResetsInput=false ', () => {

expect(instance.state.inputValue, 'to equal', 'two');
});

it('should have reset the inputValue after accepting selection', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it('should have reset the inputValue after accepting selection if onSelectResetsInput= true or not set', () => {

@JedWatson
Copy link
Owner

Thanks for the fix @dehamilton and for the review, @yuri-sakharov. I'm about to publish a new version so I've made the changes you suggested directly, so I can get this merged 👍

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.75% when pulling 552a7cd on dehamilton:master into 700b79a on JedWatson:master.

@JedWatson JedWatson merged commit a065ad4 into JedWatson:master Dec 14, 2017
@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.75% when pulling 552a7cd on dehamilton:master into 700b79a on JedWatson:master.

@@ -102,7 +102,7 @@ class Select extends React.Component {
this.setState({ required: false });
}

if (this.state.inputValue && this.props.value !== nextProps.value) {
if (this.state.inputValue && this.props.value !== nextProps.value && this.props.onSelectResetsInput) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better if (this.state.inputValue && this.props.value !== nextProps.value && nextProps.onSelectResetsInput) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @JedWatson
Sorry I didn't see the merge. Can you please also add this change?
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants