🐛 Mobile entry will enter positive value instead of negative (#1551)

Ensure our FocusableAmountInput used in MobileTransaction conditionally
applies negation logic the same way onChange as it does onBlur.
This commit is contained in:
Trevor Farlow
2023-08-20 21:15:59 -06:00
committed by GitHub
parent 6dfc43abf1
commit 2d0464c097
2 changed files with 15 additions and 4 deletions

View File

@@ -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={[

View File

@@ -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.