microsoft / microsoft/pxt-microbit
In a user-defined enumeration, the item is not selected with Blocks.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 804
- Forks
- 721
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 2
Description
FieldUserEnum
Describe the bug
No items are selected a user-defined enumerations of Radio Broadcast extensions and playground example.
playground example
Creating enumerations with blocks
https://makecode.com/defining-blocks#creating-enumerations-with-blocksPlayground example : Create Enums from Blocks
Sample: Creating Enum
Editor: micro:bit
On Blocks editor
Place the blocks as follows:
Member Red (=0) is not selected, but the display will be 0
JavaScript editor → Blocks editor
On the JavaScript editor, code as follows:
When I convert to Blocks, it shows Red instead of Blue and nothing is selected.
However, since 1 is displayed on the simulator, it appears that Blue (=1) is selected internally.
It appears that internal values are retained when blocks are copied.
Additional context
value
The format of the name is 10mem, where "10" is the value and "mem" is the enumerated member.
Therefore, it is not hit by item selection and does not become selected.
https://github.com/microsoft/pxt/blob/master/pxtblocks/fields/field_userenum.ts#L152
menu generator
The fake line is called in the createMenuGenerator function.
https://github.com/microsoft/pxt/blob/master/pxtblocks/fields/field_userenum.ts#L62
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pxtblocks/fields/field_userenum.ts, especially the createMenuGenerator function and the value handling around line 152. Reproduce the Radio Broadcast extensions example and trace JavaScript-to-Blocks conversion for a user-defined enum. Done means the correct enum member is selected and displayed in Blocks while preserving its numeric value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100