Skip to content

Commit

Permalink
Cursor focus set after selecting new currency to enter amount
Browse files Browse the repository at this point in the history
  • Loading branch information
PrashantMangukiya committed Sep 15, 2021
1 parent 9032d31 commit 0c29d63
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/pages/iou/steps/IOUAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,28 @@ class IOUAmountPage extends React.Component {
this.updateAmountNumberPad = this.updateAmountNumberPad.bind(this);
this.updateAmount = this.updateAmount.bind(this);
this.stripCommaFromAmount = this.stripCommaFromAmount.bind(this);
this.focusTextInput = this.focusTextInput.bind(this);

this.state = {
amount: props.selectedAmount,
};
}

componentDidMount() {
// Component is not initialized yet due to navigation transitions
this.focusTextInput();
}

componentDidUpdate(prevProps) {
if (this.props.iou.selectedCurrencyCode !== prevProps.iou.selectedCurrencyCode) {
this.focusTextInput();
}
}

/**
* Focus text input
*/
focusTextInput() {
// Component may not initialized due to navigation transitions
// Wait until interactions are complete before trying to focus
InteractionManager.runAfterInteractions(() => {
// Focus text input
Expand Down

0 comments on commit 0c29d63

Please sign in to comment.