diff --git a/src/frontend/src/defaults/formatters.tsx b/src/frontend/src/defaults/formatters.tsx index 8a4c6acc21..0f671a2585 100644 --- a/src/frontend/src/defaults/formatters.tsx +++ b/src/frontend/src/defaults/formatters.tsx @@ -30,7 +30,11 @@ export function formatDecimal( return value; } - let formatter = new Intl.NumberFormat(locale); + let formatter = new Intl.NumberFormat(locale, { + style: 'decimal', + maximumFractionDigits: options.digits ?? 6, + minimumFractionDigits: options.minDigits ?? 0 + }); return formatter.format(value); } diff --git a/src/frontend/src/tables/part/ParametricPartTable.tsx b/src/frontend/src/tables/part/ParametricPartTable.tsx index c5e4cc51fc..ec67fab133 100644 --- a/src/frontend/src/tables/part/ParametricPartTable.tsx +++ b/src/frontend/src/tables/part/ParametricPartTable.tsx @@ -8,6 +8,7 @@ import { useNavigate } from 'react-router-dom'; import { api } from '../../App'; import { YesNoButton } from '../../components/buttons/YesNoButton'; import { ApiFormFieldSet } from '../../components/forms/fields/ApiFormField'; +import { formatDecimal } from '../../defaults/formatters'; import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ModelType } from '../../enums/ModelType'; import { UserRoles } from '../../enums/Roles'; @@ -65,7 +66,8 @@ function ParameterCell({ parameter.data_numeric && parameter.data_numeric != parameter.data ) { - extra.push(`${parameter.data_numeric} [${template.units}]`); + const numeric = formatDecimal(parameter.data_numeric, { digits: 15 }); + extra.push(`${numeric} [${template.units}]`); } if (hovered && canEdit) { @@ -80,7 +82,7 @@ function ParameterCell({ value={value ?? '-'} extra={extra} icon={hovered && canEdit ? 'edit' : 'info'} - title={t`Internal Units`} + title={template.name} /> diff --git a/src/frontend/src/tables/part/PartParameterTable.tsx b/src/frontend/src/tables/part/PartParameterTable.tsx index 27163304d2..729e179bd3 100644 --- a/src/frontend/src/tables/part/PartParameterTable.tsx +++ b/src/frontend/src/tables/part/PartParameterTable.tsx @@ -6,6 +6,7 @@ import { useCallback, useMemo, useState } from 'react'; import { AddItemButton } from '../../components/buttons/AddItemButton'; import { YesNoButton } from '../../components/buttons/YesNoButton'; import { ApiFormFieldSet } from '../../components/forms/fields/ApiFormField'; +import { formatDecimal } from '../../defaults/formatters'; import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { UserRoles } from '../../enums/Roles'; import { usePartParameterFields } from '../../forms/PartForms'; @@ -85,7 +86,8 @@ export function PartParameterTable({ record.data_numeric && record.data_numeric != record.data ) { - extra.push(`${record.data_numeric} [${template.units}]`); + const numeric = formatDecimal(record.data_numeric, { digits: 15 }); + extra.push(`${numeric} [${template.units}]`); } return (