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
This commit is contained in:
+5
-9
@@ -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)
|
||||
}
|
||||
/>
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user