🐛 Fixed SA draft option to hold value across renders
This commit is contained in:
parent
693b94a4e2
commit
2a4c6b8656
3 changed files with 26 additions and 4 deletions
|
@ -6,9 +6,19 @@ import { formatMm, roundMm, defaultSa, sliderStep } from "@freesewing/utils";
|
||||||
import OptionPreamble from "../OptionPreamble";
|
import OptionPreamble from "../OptionPreamble";
|
||||||
|
|
||||||
const DraftSettingSa = props => {
|
const DraftSettingSa = props => {
|
||||||
const [value, setValue] = useState("dflt");
|
const [value, setValue] = useState(
|
||||||
const [saValue, setSaValue] = useState(defaultSa[props.units]);
|
props.value === defaultSa[props.units]
|
||||||
const [customValue, setCustomValue] = useState(10);
|
? "dflt"
|
||||||
|
: props.value === 0
|
||||||
|
? "none"
|
||||||
|
: "custom"
|
||||||
|
);
|
||||||
|
const [saValue, setSaValue] = useState(
|
||||||
|
props.value === null ? defaultSa[props.units] : props.value
|
||||||
|
);
|
||||||
|
const [customValue, setCustomValue] = useState(
|
||||||
|
value === "custom" ? props.value : 10
|
||||||
|
);
|
||||||
const [expanded, setExpanded] = useState(false);
|
const [expanded, setExpanded] = useState(false);
|
||||||
|
|
||||||
const update = (name, newValue, evt) => {
|
const update = (name, newValue, evt) => {
|
||||||
|
|
|
@ -66,6 +66,13 @@ const DraftSettings = props => {
|
||||||
childProps.parts[part] = <FormattedMessage id={"parts." + part} />;
|
childProps.parts[part] = <FormattedMessage id={"parts." + part} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
typeof props.gist !== "undefined" &&
|
||||||
|
typeof props.gist.settings !== "undefined" &&
|
||||||
|
typeof props.gist.settings[setting] !== "undefined"
|
||||||
|
)
|
||||||
|
childProps.value = props.gist.settings[setting];
|
||||||
|
else childProps.value = null;
|
||||||
|
|
||||||
return childProps;
|
return childProps;
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,12 @@ const OptionGroup = props => {
|
||||||
key: name,
|
key: name,
|
||||||
noDocs: props.noDocs
|
noDocs: props.noDocs
|
||||||
};
|
};
|
||||||
if (typeof props.gist.settings.options[name] !== "undefined")
|
if (
|
||||||
|
typeof props.gist !== "undefined" &&
|
||||||
|
typeof props.gist.settings !== "undefined" &&
|
||||||
|
typeof props.gist.settings.options !== "undefined" &&
|
||||||
|
typeof props.gist.settings.options[name] !== "undefined"
|
||||||
|
)
|
||||||
extraProps.value = props.gist.settings.options[name];
|
extraProps.value = props.gist.settings.options[name];
|
||||||
else extraProps.value = null;
|
else extraProps.value = null;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue