Skip to content

Commit

Permalink
🐛 Mobile entry will enter positive value instead of negative (#1551)
Browse files Browse the repository at this point in the history
Ensure our FocusableAmountInput used in MobileTransaction conditionally
applies negation logic the same way onChange as it does onBlur.
  • Loading branch information
trevdor authored Aug 21, 2023
1 parent 6dfc43a commit 2d0464c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,18 @@ export class FocusableAmountInput extends PureComponent {
});
};

maybeApplyNegative = value => {
const absValue = Math.abs(value);
return this.state.isNegative ? -absValue : absValue;
};

onBlur = value => {
this.setState({ focused: false, reallyFocused: false });
if (this.props.onBlur) {
const absValue = Math.abs(value);
this.props.onBlur(this.state.isNegative ? -absValue : absValue);
}
this.props.onBlur?.(this.maybeApplyNegative(value));
};

onChange = value => this.props.onChange?.(this.maybeApplyNegative(value));

render() {
const { textStyle, style, focusedStyle, buttonProps } = this.props;
const { focused } = this.state;
Expand All @@ -244,6 +248,7 @@ export class FocusableAmountInput extends PureComponent {
<AmountInput
{...this.props}
ref={el => (this.amount = el)}
onChange={this.onChange}
onBlur={this.onBlur}
focused={focused}
style={[
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/1551.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [trevdor]
---

Mobile: transaction entry screen should apply the same negative/positive logic to Amount whether or not it is focused for editing at the time Add Transaction is pressed.

0 comments on commit 2d0464c

Please sign in to comment.