A local-first personal finance app
:bug: Mobile entry will enter positive value instead of negative (#1551)
Trevor Farlow2d0464c0971e
diff --git a/packages/desktop-client/src/components/mobile/MobileAmountInput.js b/packages/desktop-client/src/components/mobile/MobileAmountInput.jsindex b49065c9ac..95f6ace94e 100644--- a/packages/desktop-client/src/components/mobile/MobileAmountInput.js+++ b/packages/desktop-client/src/components/mobile/MobileAmountInput.js@@ -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;@@ -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={[diff --git a/upcoming-release-notes/1551.md b/upcoming-release-notes/1551.mdnew file mode 100644index 0000000000..f0f8068ced--- /dev/null+++ b/upcoming-release-notes/1551.md@@ -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.