Commit 394b023d by feitianbubu Committed by GitHub

fix: keep group ratio input as string draft to allow decimal typing (#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 #5986
parent 2f5f6ba8
...@@ -83,7 +83,7 @@ type GroupRatioVisualEditorProps = { ...@@ -83,7 +83,7 @@ type GroupRatioVisualEditorProps = {
type GroupPricingRow = { type GroupPricingRow = {
_id: string _id: string
name: string name: string
ratio: number ratio: string
topupRatio: string topupRatio: string
selectable: boolean selectable: boolean
description: string description: string
...@@ -149,7 +149,7 @@ function buildGroupPricingRows( ...@@ -149,7 +149,7 @@ function buildGroupPricingRows(
return [...names].map((name) => ({ return [...names].map((name) => ({
_id: createGroupPricingId(), _id: createGroupPricingId(),
name, name,
ratio: normalizeRatio(ratioMap[name]), ratio: String(normalizeRatio(ratioMap[name])),
topupRatio: Object.hasOwn(topupMap, name) ? String(topupMap[name]) : '', topupRatio: Object.hasOwn(topupMap, name) ? String(topupMap[name]) : '',
selectable: Object.hasOwn(usableMap, name), selectable: Object.hasOwn(usableMap, name),
description: String(usableMap[name] ?? ''), description: String(usableMap[name] ?? ''),
...@@ -491,7 +491,7 @@ function GroupPricingTable({ ...@@ -491,7 +491,7 @@ function GroupPricingTable({
{ {
_id: createGroupPricingId(), _id: createGroupPricingId(),
name, name,
ratio: 1, ratio: '1',
topupRatio: '', topupRatio: '',
selectable: true, selectable: true,
description: '', description: '',
...@@ -567,13 +567,9 @@ function GroupPricingTable({ ...@@ -567,13 +567,9 @@ function GroupPricingTable({
type='number' type='number'
min={0} min={0}
step={0.1} step={0.1}
value={String(row.ratio)} value={row.ratio}
onChange={(event) => onChange={(event) =>
updateRow( updateRow(row._id, 'ratio', event.target.value)
row._id,
'ratio',
normalizeRatio(event.target.value)
)
} }
/> />
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment