Check for duplicates
Description
Variable fields have validators that run whenever a variable is selected from the dropdown. Importantly, the validator is not run when you rename a variable, just when you select one from the dropdown. If you have a block with a variable field validator, then rename that variable (from a different block, or via api) to a name that isn't compatible with the validator, the block will break.
note that you can't simply fix this by running the validator on the variable name change, because there could be other validators on other variable blocks that break.
Reproduction steps
- Open the Blockly Playground and switch to the Test Blocks list from the toolbox dropdown
- Select Fields -> Validators to open the Validators toolbox
- Under
Variables, drag a always null or not 1s -> null block onto the workspace
- Select the variable dropdown, then rename the variable to something without a number (for example, "a")
- Return to the Fields -> Validators -> Variables menu and drag a
force 1s block onto the workspace
- Select the variable dropdown on the
force 1s block and select the variable you renamed the other block's variable to
- Drag the
force 1s block on the workspace and attempt to drop it somewhere
Expected: you should be able to drop the block
Actual: the block is forever adhered to your cursor
Priority
Impact: this is not a very practical validator to use, so the priority is low. most variable fields are going to restrict the options that are shown by variable type, not restrict the options that can be selected.
Stack trace
playground.html?dir=ltr&toolbox=test-blocks:1 GET http://127.0.0.1:8080/tests/%3C%3C%3CPATH%3E%3E%3E/sprites.svg 404 (Not Found)
favicon.ico:1 GET http://127.0.0.1:8080/favicon.ico 404 (Not Found)
deprecation.ts:46 Blockly.Workspace.createVariable was deprecated in v12 and will be deleted in v13.
Use Blockly.Workspace.getVariableMap().createVariable instead.
(anonymous) @ deprecation.ts:46
(anonymous) @ workspace.ts:447
(anonymous) @ index.js:2
(anonymous) @ flyout_button.ts:384
(anonymous) @ browser_events.ts:71
field_variable.ts:569 Uncaught Error: Tried to call dropdownCreate on a variable field with no variable selected.
at FieldVariable.dropdownCreate [as menuGenerator_] (field_variable.ts:569:13)
at FieldVariable.getOptions (field_dropdown.ts:433:34)
at FieldVariable.getSelectedAriaLabel (field_dropdown.ts:925:12)
at FieldVariable.getAriaValue (field_dropdown.ts:907:12)
at FieldVariable.getAriaValue (field_variable.ts:630:60)
at FieldVariable.computeAriaLabel (field.ts:380:26)
at FieldVariable.recomputeAriaContext (field.ts:1563:24)
at FieldVariable.recomputeAriaContext (field_dropdown.ts:939:35)
at FieldVariable.doValueUpdate_ (field_dropdown.ts:508:12)
at FieldVariable.doValueUpdate_ (field_variable.ts:399:11)
(anonymous) @ field_variable.ts:569
(anonymous) @ field_dropdown.ts:433
(anonymous) @ field_dropdown.ts:925
(anonymous) @ field_dropdown.ts:907
(anonymous) @ field_variable.ts:630
(anonymous) @ field.ts:380
(anonymous) @ field.ts:1563
(anonymous) @ field_dropdown.ts:939
(anonymous) @ field_dropdown.ts:508
(anonymous) @ field_variable.ts:399
(anonymous) @ field.ts:1218
(anonymous) @ field_variable.ts:528
(anonymous) @ field_dropdown.ts:394
(anonymous) @ menuitem.ts:267
(anonymous) @ menu.ts:386
(anonymous) @ browser_events.ts:71
field_variable.ts:569 Uncaught Error: Tried to call dropdownCreate on a variable field with no variable selected.
at FieldVariable.dropdownCreate [as menuGenerator_] (field_variable.ts:569:13)
at FieldVariable.getOptions (field_dropdown.ts:433:34)
at FieldVariable.getSelectedAriaLabel (field_dropdown.ts:925:12)
at FieldVariable.getAriaValue (field_dropdown.ts:907:12)
at FieldVariable.getAriaValue (field_variable.ts:630:60)
at FieldVariable.computeAriaLabel (field.ts:380:26)
at block_aria_composer.ts:171:20
at Array.flatMap (<anonymous>)
at computeFieldRowLabel (block_aria_composer.ts:151:6)
at DummyInput.getLabel (input.ts:407:20)
(anonymous) @ field_variable.ts:569
(anonymous) @ field_dropdown.ts:433
(anonymous) @ field_dropdown.ts:925
(anonymous) @ field_dropdown.ts:907
(anonymous) @ field_variable.ts:630
(anonymous) @ field.ts:380
(anonymous) @ block_aria_composer.ts:171
(anonymous) @ block_aria_composer.ts:151
(anonymous) @ input.ts:407
(anonymous) @ block_aria_composer.ts:311
(anonymous) @ block_aria_composer.ts:309
(anonymous) @ block_aria_composer.ts:76
(anonymous) @ block_svg.ts:2037
(anonymous) @ block_svg.ts:2024
(anonymous) @ block_svg.ts:1909
(anonymous) @ focus_manager.ts:593
(anonymous) @ focus_manager.ts:433
(anonymous) @ layer_manager.ts:113
(anonymous) @ block_drag_strategy.ts:291
(anonymous) @ block_svg.ts:1823
(anonymous) @ dragger.ts:34
(anonymous) @ gesture.ts:310
(anonymous) @ gesture.ts:226
(anonymous) @ gesture.ts:466
(anonymous) @ browser_events.ts:73
focus_manager.ts:527 Uncaught Error: FocusManager state changes cannot happen in a tree/node focus/blur callback.
at FocusManager.ensureManagerIsUnlocked (focus_manager.ts:527:13)
at FocusManager.focusNode (focus_manager.ts:348:10)
at LayerManager.moveOffDragLayer (layer_manager.ts:138:25)
at BlockDragStrategy.endDrag (block_drag_strategy.ts:795:11)
at BlockSvg.endDrag (block_svg.ts:1836:23)
at Dragger.onDragEnd (dragger.ts:144:22)
at Gesture.handleUp (gesture.ts:508:22)
at HTMLDocument.wrapFunc (browser_events.ts:73:9)
(anonymous) @ focus_manager.ts:527
(anonymous) @ focus_manager.ts:348
(anonymous) @ layer_manager.ts:138
(anonymous) @ block_drag_strategy.ts:795
(anonymous) @ block_svg.ts:1836
(anonymous) @ dragger.ts:144
(anonymous) @ gesture.ts:508
(anonymous) @ browser_events.ts:73
workspace_svg.ts:2506 Tried to start the same gesture twice.
(anonymous) @ workspace_svg.ts:2506
(anonymous) @ field.ts:1337
(anonymous) @ browser_events.ts:71
gesture.ts:922 Uncaught Error: Tried to call gesture.setStartField, but the gesture had already been started.
at Gesture.setStartField (gesture.ts:922:13)
at FieldLabel.onMouseDown_ (field.ts:1339:15)
at SVGGElement.wrapFunc (browser_events.ts:71:14)
(anonymous) @ gesture.ts:922
(anonymous) @ field.ts:1339
(anonymous) @ browser_events.ts:71
workspace_svg.ts:2506 Tried to start the same gesture twice.
(anonymous) @ workspace_svg.ts:2506
(anonymous) @ block_svg.ts:623
(anonymous) @ browser_events.ts:71
gesture.ts:776 Uncaught Error: Tried to call gesture.handleBlockStart, but the gesture had already been started.
at Gesture.handleBlockStart (gesture.ts:776:13)
at BlockSvg.onMouseDown (block_svg.ts:625:15)
at SVGGElement.wrapFunc (browser_events.ts:71:14)
(anonymous) @ gesture.ts:776
(anonymous) @ block_svg.ts:625
(anonymous) @ browser_events.ts:71
workspace_svg.ts:2506 Tried to start the same gesture twice.
(anonymous) @ workspace_svg.ts:2506
(anonymous) @ workspace_svg.ts:1497
(anonymous) @ browser_events.ts:71
gesture.ts:715 Uncaught Error: Tried to call gesture.handleWsStart, but the gesture had already been started.
at Gesture.handleWsStart (gesture.ts:715:13)
at WorkspaceSvg.onMouseDown (workspace_svg.ts:1499:15)
at SVGGElement.wrapFunc (browser_events.ts:71:14)
(anonymous) @ gesture.ts:715
(anonymous) @ workspace_svg.ts:1499
(anonymous) @ browser_events.ts:71
gesture.ts:498 Trying to end a gesture recursively.
playground.html?dir=ltr&toolbox=test-blocks:1 GET http://127.0.0.1:8080/tests/%3C%3C%3CPATH%3E%3E%3E/handdelete.cur 404 (Not Found)
Screenshots
No response
Browsers
Chrome desktop
Check for duplicates
Description
Variable fields have validators that run whenever a variable is selected from the dropdown. Importantly, the validator is not run when you rename a variable, just when you select one from the dropdown. If you have a block with a variable field validator, then rename that variable (from a different block, or via api) to a name that isn't compatible with the validator, the block will break.
note that you can't simply fix this by running the validator on the variable name change, because there could be other validators on other variable blocks that break.
Reproduction steps
Variables, drag aalways nullornot 1s -> nullblock onto the workspaceforce 1sblock onto the workspaceforce 1sblock and select the variable you renamed the other block's variable toforce 1sblock on the workspace and attempt to drop it somewhereExpected: you should be able to drop the block
Actual: the block is forever adhered to your cursor
Priority
Impact: this is not a very practical validator to use, so the priority is low. most variable fields are going to restrict the options that are shown by variable type, not restrict the options that can be selected.
Stack trace
Screenshots
No response
Browsers
Chrome desktop