Skip to content

Label for array attributes is not hidden when using visibleIf in Script Inspector #1857

@YUNI0107

Description

@YUNI0107

Hi all, I found that when an array attribute applying a visibleif condition only hides the input fields but leaves the attribute's label visible in the Inspector UI. Here is an example code that reproduces the issue easily.

Image Image

As you can see, only the string is hidden, and the array leaves its label in the inspector.

/** @enum {string} */
const Type = {
    Show: 'show',
    Hide: 'hide',
};

export class TestFieldVisible extends Script {
    static scriptName = 'testFieldVisible';

    /**
     * @attribute
     * @title Type
     * @type {Type}
     */
    type = Type.Show;

    /**
     * @attribute
     * @title Array Feild
     * @type {string[]}
     * @visibleif {type === 'show'}
     */
    arrayFeild = [];

    /**
     * @attribute
     * @title String Feild
     * @type {string}
     * @visibleif {type === 'show'}
     */
    stringFeild = ""
}
Image

The root cause seems to be in src/editor/inspector/components/script.ts.
Inside the _updateAttributeStatus method, ArrayInput is explicitly excluded from assigning its .parent when targeting the element to be hidden.

Thanks for taking a look. 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions