scratchfoundation / scratchfoundation/scratch-blocks

field_matrix does not use colors of the block containing it

Open
#1,764 7 comments 0 reactions 3 assignees View on GitHub

Nobody has claimed this yet.

ergonomics needs discussion needs-triage
Dominant language
JavaScript
Stars
2.8k
Forks
1.6k
Avg merge
4h 51m
Merged PRs (30d)
12

Description

Expected Behavior

field_matrix should follow the colors of the block containing it.

Actual Behavior

It keeps its own greenish color:
image

I've tried to solve the issue in the PR that references this issue, but my solution feels like a hack. Because the parentBlock property isn't set on field_matix's sourceBlock_ when the affected functions are initially called I've added guards to protect against 'undefined'. This solves the issue, but feels wrong.

In contrast field_angle also references sourceBlock_.parentBlock_ but does not need the guards against parentBlock being undefined. I'm guessing that is because it only references sourceBlock_.parentBlock_ in showEditor_ which is called at a later stage than init and setValue where field_matrix sets its colors.

So perhaps the issue is that setParent should be called earlier? But that change seems like it would be above my paygrade :)

Steps to Reproduce

Add a block containing a field_matrix to an extension and the the extensions colors.
Something along the lines of:

getInfo: function () {
        return {
            blocks: [
                {
                    arguments: {
                        MATRIX: {
                            defaultValue: '0101011111111110111000100', 
                            type: 'matrix'
                        }
                    },
                    blockType: 'command',
                    opcode: 'show',
                    text: 'Show [MATRIX]'
                }
            ],
            colour: '#3D7DD9',
            colourSecondary: '#0D4E8E',
            colourTertiary: '#033D6C',
            id: 'myMatixTest',
            name: 'Matrix test',
            targetTypes: ['hub']
        };
    }
Operating System and Browser

Mac OS 10.13.6 (17G65) Chrome Version 70.0.3538.77 (Official Build) (64-bit)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.