Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

groups attribute is not properly processed #7258

Open
FranklinWhale opened this issue Jun 29, 2020 · 4 comments · May be fixed by #7609
Open

groups attribute is not properly processed #7258

FranklinWhale opened this issue Jun 29, 2020 · 4 comments · May be fixed by #7609
Assignees
Labels

Comments

@FranklinWhale
Copy link
Contributor

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

  1. Go to https://makecode.com/playground#basic-groups
  2. Click "Run"
  3. Replace //% groups="['Fruits', 'Veggies']" with //% groups=['Fruits', 'Veggies']
  4. Click "Run"
  5. Replace //% groups=['Fruits', 'Veggies'] with //% groups=["Fruits", "Veggies"]
  6. Click "Run"
  7. Replace //% groups=["Fruits", "Veggies"] with //% groups='["Fruits", "Veggies"]'
  8. Click "Run"

Actual behavior
After Step 2, 4 and 6:
image

After Step 8:
image

@pelikhan
Copy link
Member

@ganicke looks like a docs issue.

@ganicke
Copy link
Collaborator

ganicke commented Nov 10, 2020

@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 ganicke linked a pull request Nov 10, 2020 that will close this issue
@FranklinWhale
Copy link
Contributor Author

FranklinWhale commented Nov 17, 2020

@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() {

    }
}

@ganicke
Copy link
Collaborator

ganicke commented Nov 17, 2020

This is just nuts and are we sure if those are a fruit or veggie?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants