Field.text_: Documentation vs use
See original GitHub issueOur documentation is very clear about not using Field’s .text_
property.
“Warning: Never access the text_ property directly, instead access it through getText. It is maintained for backwards compatibility.” “Caution: Never use the text_ property to access or edit the text of your field. It is maintained for backwards compatibility.” https://devsite.googleplex.com/blockly/guides/create-custom-blocks/fields/customizing-fields/creating
“We recommend that you never access or update the text_ property of your field directly.” https://devsite.googleplex.com/blockly/guides/create-custom-blocks/fields/customizing-fields/upgrading
Yet our codebase uses it all over the place:
- Blockly.Block.prototype.toString
- Blockly.FieldAngle.prototype.onMouseMove
- Blockly.FieldDropdown.prototype.doValueUpdate_
- Blockly.FieldImage
- Blockly.FieldImage.prototype.initView
- Blockly.FieldImage.prototype.setAlt
- Blockly.FieldTextInput.prototype.doValueUpdate_
- Blockly.FieldTextInput.prototype.showPromptEditor_
- Blockly.FieldTextInput.prototype.widgetDispose_
- Blockly.FieldVariable.prototype.doValueUpdate_
- Blockly.FieldVariable.prototype.refreshVariableName
Is .text_
a fundamental part of fields that needs to be used whenever one creates a new field?
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (8 by maintainers)
Top GitHub Comments
Thanks for bearing with me @BeksOmega. First off, I’d very much appreciate a demo. My reservation with making this generic has been to not end up with a solution that’s pretty much the same as what we have with
this.text_
just renamed to adisplayVaue
or atempValue
.I think that’s a great idea, instead of having the field_textinput have to set the
this.text_
field directly in order to “hack” the field sizing, providing a more generic way to replace what is shown in the display would be great. I don’t see how you can do that with a single property on the field (unless that property is a DOM element), but please feel free to go ahead with a demo, I think that will give me a much better idea of your proposal.Documentation updated and will be published in the next release.