diff --git a/packages/react/components/Editor/components/menus/Input.mjs b/packages/react/components/Editor/components/menus/Input.mjs index 0477aa69ab6..564336b02c7 100644 --- a/packages/react/components/Editor/components/menus/Input.mjs +++ b/packages/react/components/Editor/components/menus/Input.mjs @@ -1,4 +1,4 @@ -import React, { useMemo, useCallback, useState } from 'react' +import React, { useCallback, useMemo, useState } from 'react' import { i18n } from '@freesewing/collection' import { designOptionType, @@ -188,7 +188,7 @@ export const MenuListToggle = ({ config, changed, updateHandler, name }) => { export const MenuMmInput = (props) => { const { updateHandler, current, config } = props - const units = props.state.settings?.units + const units = props.settings?.units const imperial = units === 'imperial' const mmUpdateHandler = useCallback( (path, newCurrent) => { @@ -201,25 +201,30 @@ export const MenuMmInput = (props) => { ) /* - * Set a default step that matches the unit + * Set a default step that matches the unit. + * + * Note that we could try to use something like 1.5875 for imperial to move in steps of 1/16 inches, + * but we round the mm values to two digits in the options, which would accumulate rounding errors. + * + * Because of this, we use 10ths of inches instead of 16ths of inches. */ - const defaultStep = units === 'imperial' ? 0.125 : 0.1 + const defaultStep = imperial ? 1.27 : 1 // mm return ( (units === 'imperial' ? formatFraction128(val, null) : val), - suffix: units === 'imperial' ? '"' : 'cm', + valFormatter: (val) => (imperial ? formatFraction128(val, null) : val), + suffix: imperial ? '"' : 'cm', }} /> ) diff --git a/packages/react/components/Editor/lib/core-settings.mjs b/packages/react/components/Editor/lib/core-settings.mjs index f048d0253ee..f93038e4ad5 100644 --- a/packages/react/components/Editor/lib/core-settings.mjs +++ b/packages/react/components/Editor/lib/core-settings.mjs @@ -102,7 +102,7 @@ export function menuCoreSettingsStructure({ units = 'metric', sabool = false, pa ), ux: config.uxLevels.core.sa, min: 0, - max: units === 'imperial' ? 2 : 2.5, + max: units === 'imperial' ? 25.4 : 25, // values are in mm dflt: defaultSamm(units), icon: SaIcon, } diff --git a/packages/utils/src/index.mjs b/packages/utils/src/index.mjs index 8f6747f544a..f6912393410 100644 --- a/packages/utils/src/index.mjs +++ b/packages/utils/src/index.mjs @@ -366,7 +366,7 @@ export function measurementAsMm(value, units = 'metric') { } else { const decimal = fractionToDecimal(value) if (isNaN(decimal)) return false - return decimal * 24.5 + return decimal * 25.4 } }