Skip to content

Commit

Permalink
fix: Input value will get selected when focused
Browse files Browse the repository at this point in the history
  • Loading branch information
saschb2b committed Sep 2, 2024
1 parent c5af0ac commit 082f75a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/components/CurrencyTextField/CurrencyTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ export const CurrencyTextField: React.FC<CurrencyTextFieldProps> = ({
}
};

/**
* Selects the input value when the input is focused.
* @param event - The focus event.
*/
const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {
event.target.select();
};

/**
* Formats the dinero value to a matching number that can be use in NumericFormat
*/
Expand Down Expand Up @@ -192,6 +200,7 @@ export const CurrencyTextField: React.FC<CurrencyTextFieldProps> = ({
min={minimumValue}
max={maximumValue}
onBlur={handleBlur}
onFocus={handleFocus}
onValueChange={handleValueChange}
{...props}
type={'text'}
Expand Down

0 comments on commit 082f75a

Please sign in to comment.