Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/components/TextInputWithCurrencySymbol.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {useState, useEffect} from 'react';
import PropTypes from 'prop-types';
import AmountTextInput from './AmountTextInput';
import CurrencySymbolButton from './CurrencySymbolButton';
Expand Down Expand Up @@ -45,6 +45,12 @@ function TextInputWithCurrencySymbol(props) {
const currencySymbol = CurrencyUtils.getLocalizedCurrencySymbol(props.selectedCurrencyCode);
const isCurrencySymbolLTR = CurrencyUtils.isCurrencySymbolLTR(props.selectedCurrencyCode);

const [skipNextSelectionChange, setSkipNextSelectionChange] = useState(false);

useEffect(() => {
setSkipNextSelectionChange(true);
}, [props.formattedAmount]);

const currencySymbolButton = (
<CurrencySymbolButton
currencySymbol={currencySymbol}
Expand All @@ -59,7 +65,13 @@ function TextInputWithCurrencySymbol(props) {
placeholder={props.placeholder}
ref={props.forwardedRef}
selection={props.selection}
onSelectionChange={props.onSelectionChange}
onSelectionChange={(e) => {
if (skipNextSelectionChange) {
setSkipNextSelectionChange(false);
return;
}
props.onSelectionChange(e);
}}
/>
);

Expand Down