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 = {
type GroupPricingRow = {
_id: string
name: string
ratio: number
ratio: string
topupRatio: string
selectable: boolean
description: string
......@@ -149,7 +149,7 @@ function buildGroupPricingRows(
return [...names].map((name) => ({
_id: createGroupPricingId(),
name,
ratio: normalizeRatio(ratioMap[name]),
ratio: String(normalizeRatio(ratioMap[name])),
topupRatio: Object.hasOwn(topupMap, name) ? String(topupMap[name]) : '',
selectable: Object.hasOwn(usableMap, name),
description: String(usableMap[name] ?? ''),
......@@ -491,7 +491,7 @@ function GroupPricingTable({
{
_id: createGroupPricingId(),
name,
ratio: 1,
ratio: '1',
topupRatio: '',
selectable: true,
description: '',
......@@ -567,13 +567,9 @@ function GroupPricingTable({
type='number'
min={0}
step={0.1}
value={String(row.ratio)}
value={row.ratio}
onChange={(event) =>
updateRow(
row._id,
'ratio',
normalizeRatio(event.target.value)
)
updateRow(row._id, 'ratio', 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