Skip to content

Interactivity API: Inability to use plain arrays in context #63651

@luisherranz

Description

@luisherranz

Description

Reported by @otakupahp in #60219 (comment)


Before 6.6 I had an array with other arrays:

array(
    array( 'id' => 1, 'item' => 'item 1 name' ),
    array( 'id' => 1, 'item' => 'item 2 name' ),
    array( 'id' => 1, 'item' => 'item 3 name' ),
);

That create this JSON:

[
    {"id":1, "item":"item 1 name"},
    {"id":2, "item":"item 2 name"},
    {"id":3, "item":"item 3 name"},
]

The Interactive API created a context object that contains the array without problems.

Now, it just renders a string instead of an array object

To fix the error, I have to modify my array into this:

array(
    'data' => array(
        array( 'id' => 1, 'item' => 'item 1 name' ),
        array( 'id' => 1, 'item' => 'item 2 name' ),
        array( 'id' => 1, 'item' => 'item 3 name' ),
    )
);

Which created this JSON:

{
    "data": [
        {"id":1, "item":"item 1 name"},
        {"id":2, "item":"item 2 name"},
        {"id":3, "item":"item 3 name"},
    ]
}

This is indeed parsed as an object.

Step-by-step reproduction instructions

Unknown yet, @otakupahp needs to provide more details.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Packages] Interactivity/packages/interactivity[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions