-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Open
Labels
component: fieldsissue: docsDescribes missing or incorrect documentationDescribes missing or incorrect documentation
Milestone
Description
Describe the bug
When constructing a number field, one passes in 4 constraints, a validator and a config object. If the config object is present, the constructor constraints are ignored, even if the config object does not replace them.
To Reproduce
.appendField(new Blockly.FieldNumber(
this.state.minLength.value, 0, Number.MAX_SAFE_INTEGER, 1,
(value) => {
if (this.state.maxLength.enabled && value > this.state.maxLength.value) {
return null
}
this.state.minLength.value = value
return value
},
{ tooltip: 'Minimum length of the string' }))This constructed field ignores the precision setting of 1. FieldNumber's constructor (lines 69-74) has this logic which produces the bug:
Blockly.FieldNumber.superClass_.constructor.call(
this, opt_value || 0, opt_validator, opt_config);
if (!opt_config) { // Only do one kind of configuration or the other.
this.setConstraints(opt_min, opt_max, opt_precision);
}Expected behavior
Constructor constraints should be used unless overridden in the config.
Ideally one would have a separate constructor with just the config object providing the constraints and validators.
Desktop (please complete the following information):
- OS:MacOS 10.15.5
- Browser chrome 83, safari 13.1
Metadata
Metadata
Assignees
Labels
component: fieldsissue: docsDescribes missing or incorrect documentationDescribes missing or incorrect documentation