Skip to content

fix: allow topup amount input to be fully cleared - #6473

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/b6d55de58
Jul 26, 2026
Merged

fix: allow topup amount input to be fully cleared#6473
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/b6d55de58

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Jul 26, 2026

Copy link
Copy Markdown
Member

⚠️ 提交说明 / PR Notice

修复钱包自定义金额输入框删到最后一位删不掉的问题

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

修复前: 无法删除1
image
修复后: 可以清空输入框
image

Summary by CodeRabbit

  • Bug Fixes
    • Preserved an intentionally cleared top-up amount instead of automatically restoring “0.”
    • Prevented the wallet from unexpectedly reinitializing the top-up amount during changes.
    • Improved minimum top-up validation and related messaging for online payment methods.
    • Ensured the initial payment amount is calculated correctly when wallet information becomes available.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

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

Changes

Wallet top-up flow

Layer / File(s) Summary
One-time top-up initialization
web/src/features/wallet/index.tsx
Uses a ref-backed guard to initialize the minimum top-up and default payment amount once after topupInfo loads.
Input and payment minimum rules
web/src/features/wallet/components/recharge-form-card.tsx
Preserves an empty amount when the top-up amount is zero and clamps standard payment-method minimums to the global minimum.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: calcium-ion

Poem

A bunny taps Backspace, light and free,
The wallet keeps the blank it meant to be.
Minimums rise where rules agree,
One top-up start blooms carefully.
Hop, hop—clean input symmetry!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy #6455 by preserving an empty amount state and avoiding reinitialization that restored the minimum value.
Out of Scope Changes check ✅ Passed The additional minimum-topup clamping is still directly related to the wallet top-up behavior and not out of scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main fix: allowing the top-up amount input to be fully cleared.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 08f88d2 and aed8946.

📒 Files selected for processing (2)
  • web/src/features/wallet/components/recharge-form-card.tsx
  • web/src/features/wallet/index.tsx

Comment on lines +140 to +151
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])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@Calcium-Ion
Calcium-Ion merged commit ab65d25 into QuantumNous:main Jul 26, 2026
2 checks passed
agogo233 pushed a commit to agogo233/new-api that referenced this pull request Jul 27, 2026
Jaykebc1 added a commit to wrouter/wrouter that referenced this pull request Jul 28, 2026
…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).
IQZZ020501 pushed a commit to IQZZ020501/new-api that referenced this pull request Jul 30, 2026
refeiner pushed a commit to wuqiang44444444/new-api that referenced this pull request Aug 17, 2026
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
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.

钱包金额输入框强制保留一位数字,无法完全清空

2 participants