Skip to content

Commit

Permalink
fix(try-it-out): required boolean default value set to --
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-lai committed Sep 30, 2020
1 parent ad630cc commit 939037c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/core/json-schema-components.jsx
Expand Up @@ -320,18 +320,16 @@ export class JsonSchema_boolean extends Component {
let { getComponent, value, errors, schema, required, disabled } = this.props
errors = errors.toJS ? errors.toJS() : []
let enumValue = schema && schema.get ? schema.get("enum") : null
if (!enumValue) {
// in case schema.get() also returns undefined/null
enumValue = fromJS(["true", "false"])
}
let allowEmptyValue = !enumValue || !required
let booleanValue = !enumValue && fromJS(["true", "false"])
const Select = getComponent("Select")

return (<Select className={ errors.length ? "invalid" : ""}
title={ errors.length ? errors : ""}
value={ String(value) }
disabled={ disabled }
allowedValues={ enumValue }
allowEmptyValue={ !required }
allowedValues={ enumValue || booleanValue }
allowEmptyValue={ allowEmptyValue }
onChange={ this.onEnumChange }/>)
}
}
Expand Down

0 comments on commit 939037c

Please sign in to comment.