Skip to content

Commit

Permalink
Merge pull request #24177 from tienifr/fix/22799
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl authored Aug 9, 2023
2 parents d1c4970 + 95be3ec commit d6a14d7
Showing 1 changed file with 14 additions and 2 deletions.
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

0 comments on commit d6a14d7

Please sign in to comment.