Skip to content

onSelectResetsInput regression fixed#2215

Merged
JedWatson merged 4 commits intoJedWatson:masterfrom
dehamilton:master
Dec 14, 2017
Merged

onSelectResetsInput regression fixed#2215
JedWatson merged 4 commits intoJedWatson:masterfrom
dehamilton:master

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

@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.


});

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

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', () => {

});

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

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', () => {

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.

}

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

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) {

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.

4 participants