scratchfoundation / scratch-blocks

Scratch Blocks is a library for building creative computing interfaces.
https://scratch.mit.edu/developers
Apache License 2.0
2.59k stars 1.38k forks source link

Menu values that are numbers cause errors #1261

Open ericrosenbaum opened 6 years ago

ericrosenbaum commented 6 years ago

Expected Behavior

In a menu field constructed from text/value pairs, the values should work if they are numbers or strings.

Actual Behavior

If the values are numbers instead of strings, manipulating the block causes errors. For example, selecting a menu item on the block and then deleting it causes this error: Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

Steps to Reproduce

Blockly.Blocks['sound_sounds_menu'] = {
  /**
   * Sound effects drop-down menu.
   * @this Blockly.Block
   */
  init: function() {
    this.jsonInit(
      {
        "message0": "%1",
        "args0": [
          {
            "type": "field_dropdown",
            "name": "SOUND_MENU",
            "options": [
              ['a', 1],
              ['b', 2],
              ['c', 3],
            ]
          }
        ],
        "colour": Blockly.Colours.sounds.secondary,
        "colourSecondary": Blockly.Colours.sounds.secondary,
        "colourTertiary": Blockly.Colours.sounds.tertiary,
        "extensions": ["output_string"]
      });
  }
};
zCrin commented 6 years ago

Same trouble !! Did you find a workaround or do we need to "stringify" our ints ?

BrightLin commented 5 years ago

Same trouble! Maybe "field_dropdown" cannot use number-only. I found the phenomenon.

Ceeson commented 4 years ago

Same trouble! Maybe "field_dropdown" cannot use number-only. I found the phenomenon.

thanks!!