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

View file

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