Skip to content

Commit

Permalink
Focus total amount effect
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Jan 3, 2024
1 parent c896b46 commit ec6a309
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,17 @@ const TransactionEditInner = memo(function TransactionEditInner({

const onTotalAmountEdit = () => {
onRequestActiveEdit?.(getFieldName(transaction.id, 'amount'), () => {
totalAmountRef.current?.focus();
setTotalAmountFocused(true);
return () => {
totalAmountRef.current?.blur();
setTotalAmountFocused(false);
};
return () => setTotalAmountFocused(false);
});
};

useEffect(() => {
if (totalAmountFocused) {
totalAmountRef.current?.focus();
}
}, [totalAmountFocused]);

useEffect(() => {
if (adding) {
onTotalAmountEdit();
Expand Down

0 comments on commit ec6a309

Please sign in to comment.