fix: allow topup amount input to be fully cleared - #6473
Conversation
WalkthroughThe wallet now initializes top-up state once after loading, preserves intentionally empty amount input, and enforces the greater of per-method and global minimum top-up amounts for standard payment methods. ChangesWallet top-up flow
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/features/wallet/index.tsx`:
- Around line 140-151: The initialization effect should use the default payment
method’s effective minimum rather than the global minimum from
getMinTopupAmount. In the topupInfo initialization block, derive the default
method first, calculate max(method.min_topup, global minimum), and pass that
amount to setTopupAmount and calculatePaymentAmount so the selected default
method remains enabled.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 733ee9a5-8d7d-4da2-93b7-7f5191855f9f
📒 Files selected for processing (2)
web/src/features/wallet/components/recharge-form-card.tsxweb/src/features/wallet/index.tsx
| const topupAmountInitializedRef = useRef(false) | ||
| useEffect(() => { | ||
| if (topupInfo && topupAmount === 0) { | ||
| if (topupInfo && !topupAmountInitializedRef.current) { | ||
| topupAmountInitializedRef.current = true | ||
| const minTopup = getMinTopupAmount(topupInfo) | ||
| setTopupAmount(minTopup) | ||
|
|
||
| // Calculate initial payment amount with default payment type | ||
| const defaultPaymentType = getDefaultPaymentType(topupInfo) | ||
| calculatePaymentAmount(minTopup, defaultPaymentType) | ||
| } | ||
| }, [topupInfo, topupAmount, calculatePaymentAmount]) | ||
| }, [topupInfo, calculatePaymentAmount]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Initialize using the default payment method’s effective minimum.
getMinTopupAmount(topupInfo) returns only the global minimum, while RechargeFormCard disables each standard method at max(method.min_topup, global minimum). If the first default method requires more than the global minimum, this initializes and calculates a payment amount for a method whose button is disabled. Derive the initial amount from the selected method’s effective minimum, or select a method valid at the initialized amount.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/src/features/wallet/index.tsx` around lines 140 - 151, The initialization
effect should use the default payment method’s effective minimum rather than the
global minimum from getMinTopupAmount. In the topupInfo initialization block,
derive the default method first, calculate max(method.min_topup, global
minimum), and pass that amount to setTopupAmount and calculatePaymentAmount so
the selected default method remains enabled.
…bounce) Bring the aurora theme to parity with two rc.22 upstream web fixes that aurora reproduces (aurora is a separate implementation, so upstream web/ fixes don't carry over automatically): - Top-up amount input can now be fully cleared (QuantumNous#6473): preserve an empty localAmount instead of resetting to '0', and guard the one-time amount initialization with a ref instead of 'topupAmount === 0' so clearing the field no longer refills it. - Users page search is debounced 500ms (QuantumNous#6474) via the existing data-table toolbar searchDebounceMs prop. Other rc.22 web fixes (inline channel-priority edit, unset-price models tab, JSON editor unify, data-table column toggle) target upstream-specific components; aurora uses different implementations (e.g. channel cards vs inline table) or lacks the view, so they don't apply. aurora build + typecheck clean (6 pre-existing warnings, no new).
修复钱包自定义金额输入框删到最后一位删不掉的问题
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
修复前: 无法删除1


修复后: 可以清空输入框
Summary by CodeRabbit