When creating a range order with a premium, if the user submits the form within ~2 seconds of typing the premium value (without tapping another field first), the order is created with premium: 0 instead of the entered value.
To Reproduce
- Open the new order form
- Select sell and enable range mode (set min and max fiat amount)
- Fill in all fields (currency, payment method, min: 1, max: 100)
- Type a premium value (e.g. 7)
- Immediately tap the submit button without tapping any other field
Expected behavior
The order is created with premium: 7.
Actual behavior
The order is created with premium: 0. Confirmed on Android APK and Linux client.
Root cause
In premium_section.dart, text field changes are debounced by 2 seconds before calling onChanged (which updates _premiumValue in the parent). The value is also committed on focus loss via _commitTextValue(), but tapping the submit button does not always trigger a focus loss event in Flutter.
If the user submits within the 2-second debounce window without losing focus, _premiumValue in add_order_screen.dart is still 0.0 and the order is sent with premium: 0.
Suggested fix
Add FocusScope.of(context).unfocus() at the start of the submit handler in add_order_screen.dart to force the premium field to commit its value before the order is constructed. Alternatively, read the premium value directly from the TextEditingController at submission time instead of relying on the debounced callback.
Additional context
- Intermittent by nature: if the user waits 2+ seconds after typing the premium, or taps another field before submitting, the correct value is sent.
- Affects range orders specifically because the reproduction steps involve the range mode flow, though the bug likely affects single-amount orders too.
When creating a range order with a premium, if the user submits the form within ~2 seconds of typing the premium value (without tapping another field first), the order is created with premium: 0 instead of the entered value.
To Reproduce
Expected behavior
The order is created with premium: 7.
Actual behavior
The order is created with premium: 0. Confirmed on Android APK and Linux client.
Root cause
In premium_section.dart, text field changes are debounced by 2 seconds before calling onChanged (which updates _premiumValue in the parent). The value is also committed on focus loss via _commitTextValue(), but tapping the submit button does not always trigger a focus loss event in Flutter.
If the user submits within the 2-second debounce window without losing focus, _premiumValue in add_order_screen.dart is still 0.0 and the order is sent with premium: 0.
Suggested fix
Add FocusScope.of(context).unfocus() at the start of the submit handler in add_order_screen.dart to force the premium field to commit its value before the order is constructed. Alternatively, read the premium value directly from the TextEditingController at submission time instead of relying on the debounced callback.
Additional context