Skip to content

fix: 分组倍率 Ratio 输入框保留小数中间态,修复无法输入 0.05 - #5995

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:fix/group-ratio-decimal-input
Jul 7, 2026
Merged

Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:fix/group-ratio-decimal-input

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Jul 7, 2026 •

Copy link
Copy Markdown
Member

📝 变更描述 / Description

分组定价表格的 Ratio 列每敲一个键就把输入值 Number() 化再回填,输入 0.05 走到 0.0 时被折叠成 0,小数没法继续输。

改法对齐同文件充值倍率(Top-up ratio)列的既有做法:GroupPricingRow.ratio 改成字符串草稿,输入过程不做转换,只在 serializeGroupPricingRows() 序列化时经 normalizeRatio 转 number。输入期间父组件 props 回流时 groupPricingSignature 比较的是序列化后的数值,0.0 与 0 签名一致,rows 不会被重建,草稿得以保留——这也是充值倍率列一直没这个问题的原因。空值等边界的落库行为与改动前一致。

🚀 变更类型 / Type of change

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

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

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

📸 运行证明 / Proof of Work

image

Summary by CodeRabbit

  • Bug Fixes
    • Improved editing of group pricing ratios so values entered in the table behave more consistently.
    • New rows now start with a ratio of 1, matching the displayed input format.
    • Ratio fields now preserve the exact value being typed before saving, reducing unexpected changes while editing.

The ratio column normalized input to number on every keystroke, so
typing 0.05 got stuck at 0.0 which Number() collapses to 0. Keep the
value as a string draft like the top-up ratio column and only convert
to number when serializing.

Fixes QuantumNous#5986
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 1fb91dba-f724-4045-9c83-7a0357bd2e62

📥 Commits

Reviewing files that changed from the base of the PR and between 2f5f6ba and 4e3146c.

📒 Files selected for processing (1)
  • web/default/src/features/system-settings/models/group-ratio-visual-editor.tsx

Walkthrough

The ratio field in the group pricing visual editor changes representation from number to string. Row construction, default values, and the ratio input binding are updated to work with strings, deferring numeric normalization to serialization time.

Changes

Ratio Input Handling

Layer / File(s) Summary
Ratio type and row construction
web/default/src/features/system-settings/models/group-ratio-visual-editor.tsx
GroupPricingRow.ratio type changes from number to string; buildGroupPricingRows assigns a normalized string ratio; default ratio for new rows becomes '1'.
Ratio input binding
web/default/src/features/system-settings/models/group-ratio-visual-editor.tsx
The ratio <Input> binds directly to the string row.ratio and stores raw event.target.value on change, removing immediate normalization.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit typed "0.0" with glee,
No more snapping back to "0" for me!
Strings now hold my digits tight,
Till 0.05 comes out 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 title clearly describes the core fix: preserving decimal intermediate states in the Ratio input so 0.05 can be entered.
Linked Issues check ✅ Passed The changes match #5986 by keeping Ratio edits as strings and normalizing only on serialization, preserving in-progress decimal input.
Out of Scope Changes check ✅ Passed The PR stays scoped to the Ratio editor fix in one file with no unrelated feature changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@Calcium-Ion
Calcium-Ion merged commit 394b023 into QuantumNous:main Jul 7, 2026
1 check passed
wuwenrui pushed a commit to wuwenrui/new-api that referenced this pull request Jul 7, 2026
…uantumNous#5995)

The ratio column normalized input to number on every keystroke, so
typing 0.05 got stuck at 0.0 which Number() collapses to 0. Keep the
value as a string draft like the top-up ratio column and only convert
to number when serializing.

Fixes QuantumNous#5986
xiaomingchen pushed a commit to xiaomingchen/new-api that referenced this pull request Jul 10, 2026
…uantumNous#5995)

The ratio column normalized input to number on every keystroke, so
typing 0.05 got stuck at 0.0 which Number() collapses to 0. Keep the
value as a string draft like the top-up ratio column and only convert
to number when serializing.

Fixes QuantumNous#5986
Jacobinwwey pushed a commit to Jacobinwwey/new-api that referenced this pull request Jul 11, 2026
…uantumNous#5995)

The ratio column normalized input to number on every keystroke, so
typing 0.05 got stuck at 0.0 which Number() collapses to 0. Keep the
value as a string draft like the top-up ratio column and only convert
to number when serializing.

Fixes QuantumNous#5986
ruanhangjian pushed a commit to ruanhangjian/new-api that referenced this pull request Jul 11, 2026
…uantumNous#5995)

The ratio column normalized input to number on every keystroke, so
typing 0.05 got stuck at 0.0 which Number() collapses to 0. Keep the
value as a string draft like the top-up ratio column and only convert
to number when serializing.

Fixes QuantumNous#5986
lizhongyi1209 pushed a commit to lizhongyi1209/new-api that referenced this pull request Jul 13, 2026
…uantumNous#5995)

The ratio column normalized input to number on every keystroke, so
typing 0.05 got stuck at 0.0 which Number() collapses to 0. Keep the
value as a string draft like the top-up ratio column and only convert
to number when serializing.

Fixes QuantumNous#5986

(cherry picked from commit 394b023)
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
…uantumNous#5995)

The ratio column normalized input to number on every keystroke, so
typing 0.05 got stuck at 0.0 which Number() collapses to 0. Keep the
value as a string draft like the top-up ratio column and only convert
to number when serializing.

Fixes QuantumNous#5986
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
…uantumNous#5995)

The ratio column normalized input to number on every keystroke, so
typing 0.05 got stuck at 0.0 which Number() collapses to 0. Keep the
value as a string draft like the top-up ratio column and only convert
to number when serializing.

Fixes QuantumNous#5986
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
…uantumNous#5995)

The ratio column normalized input to number on every keystroke, so
typing 0.05 got stuck at 0.0 which Number() collapses to 0. Keep the
value as a string draft like the top-up ratio column and only convert
to number when serializing.

Fixes QuantumNous#5986
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
…uantumNous#5995)

The ratio column normalized input to number on every keystroke, so
typing 0.05 got stuck at 0.0 which Number() collapses to 0. Keep the
value as a string draft like the top-up ratio column and only convert
to number when serializing.

Fixes QuantumNous#5986
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.

新版前端分组倍率 Ratio 输入 0.0 会立即变成 0,导致难以输入 0.05

2 participants