Skip to content

Premium value not sent when submitting order quickly after typing #554

@21Mill

Description

@21Mill

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

  1. Open the new order form
  2. Select sell and enable range mode (set min and max fiat amount)
  3. Fill in all fields (currency, payment method, min: 1, max: 100)
  4. Type a premium value (e.g. 7)
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions