groups attribute is not properly processed
Describe the bug
According to https://makecode.com/defining-blocks#category,
To define your groups, add the groups attribute to your namespace. The groups attribute is an array of group names.
The order in which you define your groups is the order in which the groups will appear in the toolbox flyout
, and it has a sample syntax of the groups attribute:
//% groups=['LED matrix', 'Control flow', 'others']
Unfortunately, that does work.
On https://makecode.com/playground#basic-groups, another syntax is shown:
//% groups="['Fruits', 'Veggies']"
Sadly, that does not work either.
The only syntax that appears to work is as follows:
//% groups='["Fruits", "Veggies"]'
I think either the above samples should amended, or the parser should support all of them.
To Reproduce
- Go to https://makecode.com/playground#basic-groups
- Click "Run"
- Replace
//% groups="['Fruits', 'Veggies']"with//% groups=['Fruits', 'Veggies'] - Click "Run"
- Replace
//% groups=['Fruits', 'Veggies']with//% groups=["Fruits", "Veggies"] - Click "Run"
- Replace
//% groups=["Fruits", "Veggies"]with//% groups='["Fruits", "Veggies"]' - Click "Run"
Actual behavior
After Step 2, 4 and 6:

After Step 8:

@ganicke looks like a docs issue.
@pelikhan - It seems that the first member of the namespace with its group attribute set determines the display order in the Toolbox and not the order set for groups. The playground example below will cause the Fruits group to display first despite the order of groups.
/**
* Organize your blocks in groups
*/
//% color="#AA278D"
//% groups="['Veggies', 'Fruits']"
namespace food {
//% block
//% group="Fruits"
export function apple() {
}
//% block
//% group="Veggies"
export function potato() {
}
//% block
//% group="Fruits"
export function banana() {
}
//% block
//% group="Veggies"
export function bean() {
}
}
@ganicke I think the groups attribute is working, if it is specified in the correct format. The code below should work:
/**
* Organize your blocks in groups
*/
//% color="#AA278D"
//% groups='["Veggies", "Fruits"]'
namespace food {
//% block
//% group="Fruits"
export function apple() {
}
//% block
//% group="Veggies"
export function potato() {
}
//% block
//% group="Fruits"
export function banana() {
}
//% block
//% group="Veggies"
export function bean() {
}
}
This is just nuts and are we sure if those are a fruit or veggie?