mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-29 22:54:39 +01:00
Always have default value if value not set
This commit is contained in:
parent
766a3e387e
commit
a8a3b7a5ad
3 changed files with 4 additions and 6 deletions
|
@ -46,7 +46,7 @@ export default class PropertyGroup extends React.Component {
|
|||
onChange={this.onPropertyChange.bind(this)}
|
||||
key={fieldName}
|
||||
fieldName={fieldName}
|
||||
value={fieldValue}
|
||||
value={fieldValue === undefined ? fieldSpec.default : fieldValue}
|
||||
fieldSpec={fieldSpec}
|
||||
/>
|
||||
})
|
||||
|
|
|
@ -51,8 +51,8 @@ export default class SpecField extends React.Component {
|
|||
render() {
|
||||
const commonProps = {
|
||||
style: this.props.style,
|
||||
default: this.props.fieldSpec.default,
|
||||
value: this.props.value,
|
||||
default: this.props.fieldSpec.default,
|
||||
name: this.props.fieldName,
|
||||
onChange: newValue => this.props.onChange(this.props.fieldName, newValue)
|
||||
}
|
||||
|
@ -70,13 +70,11 @@ export default class SpecField extends React.Component {
|
|||
if(options.length <= 3 && optionsLabelLength(options) <= 20) {
|
||||
return <MultiButtonInput
|
||||
{...commonProps}
|
||||
value={this.props.value || this.props.fieldSpec.default}
|
||||
options={options}
|
||||
/>
|
||||
} else {
|
||||
return <SelectInput
|
||||
{...commonProps}
|
||||
value={this.props.value || this.props.fieldSpec.default}
|
||||
options={options}
|
||||
/>
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import { margins } from '../../config/scales'
|
|||
|
||||
class CheckboxInput extends React.Component {
|
||||
static propTypes = {
|
||||
value: React.PropTypes.string,
|
||||
value: React.PropTypes.bool.isRequired,
|
||||
style: React.PropTypes.object,
|
||||
onChange: React.PropTypes.func,
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class CheckboxInput extends React.Component {
|
|||
...styles.input,
|
||||
...this.props.style,
|
||||
}}
|
||||
onChange={e => {this.props.onChange(!this.props.value)}}
|
||||
onChange={e => this.props.onChange(!this.props.value)}
|
||||
checked={this.props.value}
|
||||
/>
|
||||
<div style={styles.box}>
|
||||
|
|
Loading…
Reference in a new issue