Skip to content

Commit

Permalink
Fixes patw0929#260: Fix cursor position
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Bubała committed Jan 8, 2019
1 parent 6c8ce61 commit df9c35d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/IntlTelInputApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class IntlTelInputApp extends Component {
componentDidUpdate(prevProps) {
if (this.props.value !== prevProps.value) {
this.updateFlagFromNumber(this.props.value);
this.updateCursorPosition((this.props.value || this.props.defaultValue).length);
}

if (
Expand Down Expand Up @@ -677,6 +678,12 @@ class IntlTelInputApp extends Component {
return number;
};

updateCursorPosition = (cursorPosition) => {
this.setState({
cursorPosition,
});
}

// update the input's value to the given val (format first if possible)
// if doNotify is true, calls notifyPhoneNumberChange with the formatted value
// NOTE: this is called from _setInitialState, handleUtils and setNumber
Expand Down

0 comments on commit df9c35d

Please sign in to comment.