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

Fix: invoke onPhoneNumberChange callback with formatted value on init instead of unformatted value from previous state #283

Merged
merged 1 commit into from
Oct 9, 2019

Conversation

coox
Copy link
Contributor

@coox coox commented Mar 27, 2019

Description

When using formatOnInit in conjunction with onPhoneNumberChange, a bug causes the latter callback to be invoked with a value from the not-yet-formatted previous state.

This change fixes this behavior and notifies the callback with the updated, formatted value.

I have tried to write two test cases (default and formatOnInit=false), but unfortunately, my knowledge of Enzyme is too limited 😥️ The behavior relies on libphonenumber-js-utils to be done loading, so the test cases must run after the deferred are resolved…

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have used ESLint & Prettier to follow the code style of this project.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

…instead of unformatted value from previous state
@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.255% when pulling 71d2be1 on coox:master into 3f9b3c7 on patw0929:master.

@patw0929 patw0929 merged commit 34357e2 into patw0929:master Oct 9, 2019
patw0929 added a commit that referenced this pull request Oct 9, 2019
Bug fixes:

* #302: Remove package-lock.json
* #283: Fix: invoke onPhoneNumberChange callback with formatted value on init instead of unformatted value from previous state
* #300: fixed bug with pasting number over another number
* #299: Use cross-env to solve cross platforms issue (scripts with node env variables)

Docs:

* #298: Update LICENSE
* #297: Update README.md
* #294: Removed bash highlighting for npm/yarn commands in README
andrewsantarin pushed a commit to andrewsantarin/react-intl-tel-input that referenced this pull request Feb 2, 2022
Fix: invoke onPhoneNumberChange callback with formatted value on init instead of unformatted value from previous state
andrewsantarin pushed a commit to andrewsantarin/react-intl-tel-input that referenced this pull request Feb 2, 2022
Bug fixes:

* patw0929#302: Remove package-lock.json
* patw0929#283: Fix: invoke onPhoneNumberChange callback with formatted value on init instead of unformatted value from previous state
* patw0929#300: fixed bug with pasting number over another number
* patw0929#299: Use cross-env to solve cross platforms issue (scripts with node env variables)

Docs:

* patw0929#298: Update LICENSE
* patw0929#297: Update README.md
* patw0929#294: Removed bash highlighting for npm/yarn commands in README
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.

3 participants