Skip to content

Commit

Permalink
Merge pull request patw0929#198 from MatthewAnstey/bug/delete-country…
Browse files Browse the repository at this point in the history
…-code

Allow country code to be deleted
  • Loading branch information
patw0929 committed Mar 2, 2018
2 parents 1178d05 + f27a69f commit 611c8a5
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 611c8a5

Please sign in to comment.