blockly: Shadow block dropdown gets color of parent category

Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

If a shadow block has a dropdown, it gets the color of the parent category, instead of the color of the block own category.

Reproduction steps

  1. Run npm run start and click the Advanced playground link to go to the advanced playground…
  2. Load the following JSON into the playground:
{
  "blocks": {
    "languageVersion": 0,
    "blocks": [
      {
        "type": "controls_whileUntil",
        "inputs": {
          "BOOL": {
            "shadow": {
              "type": "logic_boolean"
            }
          }
        }
      }
    ]
  }
}
  1. Click on the dropdown block.
  2. Observe how the dropdown has the color of the parent.

Stack trace

No response

Screenshots

Tested on https://www.supercodingball.com/code/offline/do-nothing:

https://github.com/google/blockly/assets/7261426/6300537c-7df8-453a-89aa-c71378838339

Browsers

Chrome desktop

To Fix

  1. Run the reproduction steps to make sure you can reproduce the problem.
  2. Modify the showEditor_ method in the FieldDropdown to always show the current block color (instead of showing the parent colour when the block is a shadow).
  3. Rerun the reproduction steps and make sure you can’t reproduce the problem…

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 27 (18 by maintainers)

Commits related to this issue

Most upvoted comments

@BeksOmega I don’t see the issue in this ?

Sorry should have clarified, this is a zelos-specific issue, so you need to switch to the zelos renderer. It’s in the right side bar under “Options”

Hey, Thanks a lot ! @BeksOmega, One more question, I read the conversation, and I believe if I do this, this will solve the issue Modify the showEditor_ method in the FieldDropdown to always show the current block color (instead of showing the parent colour when the block is a shadow).

Ok I added fix instructions to this issue so that dropdowns will always match the color of the given block.

And I separated out the shadow blocks matching parents question into a separate issue: https://github.com/google/blockly/issues/7607

TL:DR, I don’t really like the idea of adding another constant, because I think it breaks separation of responsibility and isn’t super sustainable. I think we should see if we can migrate to using CSS for themes if possible, but I still need to dig into this.

Right, the dropdown should match the shadow block in both cases.

The proposal above to introduce SHADOW_BLOCKS_USE_PARENT_STYLE = false as a renderer constant applies to the whole block including its dropdown (and so could be considered separately from this issue since it requires bigger changes).