🐛 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";
|
||||
|
||||
const DraftSettingSa = props => {
|
||||
const [value, setValue] = useState("dflt");
|
||||
const [saValue, setSaValue] = useState(defaultSa[props.units]);
|
||||
const [customValue, setCustomValue] = useState(10);
|
||||
const [value, setValue] = useState(
|
||||
props.value === defaultSa[props.units]
|
||||
? "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 update = (name, newValue, evt) => {
|
||||
|
|
|
@ -66,6 +66,13 @@ const DraftSettings = props => {
|
|||
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;
|
||||
};
|
||||
|
|
|
@ -28,7 +28,12 @@ const OptionGroup = props => {
|
|||
key: name,
|
||||
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];
|
||||
else extraProps.value = null;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue