Skip to content

fix: commit premium field value before order submission#555

Merged
grunch merged 1 commit into
MostroP2P:mainfrom
21Mill:fix/premium-debounce-on-submit
Mar 31, 2026
Merged

fix: commit premium field value before order submission#555
grunch merged 1 commit into
MostroP2P:mainfrom
21Mill:fix/premium-debounce-on-submit

Conversation

@21Mill
Copy link
Copy Markdown
Contributor

@21Mill 21Mill commented Mar 29, 2026

When submitting an order immediately after typing the premium value (within the 2s debounce window), the premium was sent as 0 because PremiumSection had not yet fired onChanged to the parent.

Calling primaryFocus?.unfocus() at the start of _submitOrder() synchronously triggers the FocusNode listener, which cancels the debounce timer and calls _commitTextValue() → widget.onChanged() → setState({ _premiumValue = value }) before the Order object is built.

Closes #554

Summary by CodeRabbit

  • Bug Fixes
    • Improved order form submission to ensure all active text field inputs are properly committed before validation, addressing potential timing issues with data entry and form processing.

When submitting an order immediately after typing the premium value
(within the 2s debounce window), the premium was sent as 0 because
PremiumSection had not yet fired onChanged to the parent.

Calling primaryFocus?.unfocus() at the start of _submitOrder()
synchronously triggers the FocusNode listener, which cancels the
debounce timer and calls _commitTextValue() → widget.onChanged() →
setState({ _premiumValue = value }) before the Order object is built.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3a0a2fe0-e3df-4cbf-9188-18442cde0f96

📥 Commits

Reviewing files that changed from the base of the PR and between 09b7217 and 935a8d0.

📒 Files selected for processing (1)
  • lib/features/order/screens/add_order_screen.dart

Walkthrough

Added primaryFocus?.unfocus() call at the start of the _submitOrder() method to ensure pending text field edits are committed before form validation and controller value reads, addressing a timing issue where rapidly-submitted premium values were not being captured.

Changes

Cohort / File(s) Summary
Focus Unfocus Fix
lib/features/order/screens/add_order_screen.dart
Added primaryFocus?.unfocus() at the start of _submitOrder() to force commit of text field edits before validation, resolving issue where premium values entered and submitted within the 2-second debounce window were not being captured.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Suggested reviewers

  • mostronator
  • grunch

Poem

🐰 A flutter field that lost its way,
Debounced values in delay,
But unfocus calls the truth to light,
Premium values sent just right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically identifies the main change: adding focus unfocus to commit the premium field value before order submission, which directly addresses the root cause of issue #554.
Linked Issues check ✅ Passed The PR implementation matches the linked issue #554 requirements by calling primaryFocus?.unfocus() at the start of _submitOrder() to synchronously trigger focus listeners and commit pending field values before form validation and order construction.
Out of Scope Changes check ✅ Passed The PR contains only the necessary change to fix issue #554: adding primaryFocus?.unfocus() in _submitOrder(). No other modifications or unrelated changes were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Member

@Catrya Catrya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK
Wellcome @21Mill thanks for the contribution!

Copy link
Copy Markdown
Member

@AndreaDiazCorreia AndreaDiazCorreia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@grunch grunch merged commit a4a9b64 into MostroP2P:main Mar 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Premium value not sent when submitting order quickly after typing

4 participants