Skip to content

Commit

Permalink
Allow country code to be deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Anstey committed Feb 24, 2018
1 parent dcfe6e2 commit c731a6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 10 additions & 0 deletions __tests__/TelInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,16 @@ describe('TelInput', function () { // eslint-disable-line func-names
subject.setProps({ value: 'foo bar' });
expect(inputComponent.props().value).toBe('foo bar');
});

it('should be able to delete country code after input field has been populated with number', () => {
const subject = this.makeSubject();

subject.setProps({ value: '+447598455159' });

subject.setProps({ value: '+' });

expect(subject.state().value).toBe('+');
});
});

describe('uncontrolled', () => {
Expand Down
3 changes: 0 additions & 3 deletions src/components/IntlTelInputApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,6 @@ class IntlTelInputApp extends Component {
// Note: use getNumeric here because the number has not been
// formatted yet, so could contain bad chars
countryCode = null;
} else if (!number || number === '+') {
// empty, or just a plus, so default
countryCode = this.defaultCountry;
}

if (countryCode !== null) {
Expand Down

0 comments on commit c731a6b

Please sign in to comment.