Fix toggleable form fields
@@ -343,11 +343,8 @@ class ScriptEventField extends Component {
</div>
);
}
- return (
- <FormField halfWidth={field.width === "50%"}>
- <label htmlFor={genKey(eventId, field.key)}>
- {field.type !== "checkbox" && field.type !== "group" && label}
- {field.multiple ? (
+
+ const inputField = field.multiple ? (
value.map((_, valueIndex) => {
const fieldId = genKey(eventId, field.key, valueIndex);
return (
@@ -389,7 +386,26 @@ class ScriptEventField extends Component {
args={args}
onChange={this.onChange}
/>
- )}
+ );
+
+ if (field.toggleLabel) {
+ return (
+ <ToggleableFormField
+ htmlFor={genKey(eventId, field.key)}
+ closedLabel={field.toggleLabel}
+ label={field.label}
+ open={!!value}
+ >
+ {inputField}
+ </ToggleableFormField>
+ );
+ }
+
+ return (
+ <FormField halfWidth={field.width === "50%"}>
+ <label htmlFor={genKey(eventId, field.key)}>
+ {field.type !== "checkbox" && field.type !== "group" && label}
+ {inputField}
{field.type === "checkbox" && label}
</label>
</FormField>
