Fix switch onChange

This commit is contained in:
Krzysztof Bialoglowicz 2019-08-28 10:29:06 +02:00
parent 4d4f5b4b66
commit 1f3bcf1a3c
2 changed files with 8 additions and 4 deletions

View file

@ -21,8 +21,8 @@ interface PluginSettingsProps {
const styles = createStyles({ const styles = createStyles({
item: { item: {
paddingBottom: 5, paddingBottom: 10,
paddingTop: 5 paddingTop: 10
} }
}); });
@ -57,7 +57,11 @@ const PluginSettings = withStyles(styles, { name: "PluginSettings" })(
)} )}
{configuration.type === "BOOLEAN" && ( {configuration.type === "BOOLEAN" && (
<ControlledSwitch <ControlledSwitch
checked={configuration.value === "true"} checked={
typeof configuration.value !== "boolean"
? configuration.value === "true"
: configuration.value
}
label={configuration.label} label={configuration.label}
name={configuration.name} name={configuration.name}
onChange={onChange} onChange={onChange}

View file

@ -50,6 +50,7 @@ const PageDetailsPage: React.StatelessComponent<PageDetailsPageProps> = ({
description: maybe(() => plugin.description, ""), description: maybe(() => plugin.description, ""),
name: maybe(() => plugin.name, "") name: maybe(() => plugin.name, "")
}; };
return ( return (
<Form errors={errors} initial={initialForm} onSubmit={onSubmit}> <Form errors={errors} initial={initialForm} onSubmit={onSubmit}>
{({ data, errors, hasChanged, submit, set, triggerChange }) => { {({ data, errors, hasChanged, submit, set, triggerChange }) => {
@ -63,7 +64,6 @@ const PageDetailsPage: React.StatelessComponent<PageDetailsPageProps> = ({
name === "active" name === "active"
? (newData.active = value) ? (newData.active = value)
: (newData.active = data.active); : (newData.active = data.active);
newData.configuration.map(item => { newData.configuration.map(item => {
if (item.name === name) { if (item.name === name) {
item.value = value; item.value = value;