Order of assets.colors.get() not matching order in assets panel

Order of assets.colors.get() not matching order in assets panel

The array returned from assets.colors.get() is in the incorrect order based on API docs.

API documentation states

Get a list of all color/gradient assets, in the order they appear in the Assets panel.

Link to docs

However, that doesn’t appear to be the case.

Steps to reproduce

Create XD doc
Make some color assets
Re-order them in the assets panel by dragging and dropping.
Run a plugin that will get the color assets and log that returned array to the console.

Expected Behavior

The order of colors in the array are in the order shown in the assets panel.
Based on the image above:
[ { name: ‘Yellow’, color: { value: 4293450561 } },
{ name: ‘Blue’, color: { value: 4282479016 } },
{ name: ‘Orange’, color: { value: 4294084878 } },
{ name: ‘Pink’, color: { value: 4292062637 } },
{ name: ‘Green’, color: { value: 4281303416 } },
{ name: ‘Red’, color: { value: 4290387743 } } ]

Actual Behavior

They are returned in the order shown in the image above. I believe they are shown in the order they were created in, not the order they currently appear in.

Additional information

Allowing the array to be ordered by how the colors or arranged in the assets panel is desired. Please fight the urge to just update the docs with actual, current, behavior as opposed to fixing colors.get() behavior. :smiley:

Thanks for reporting this issue with detailed description and screenshots. I was able to reproduce the issue. I will work with the XD engineering team to discuss how we should go about addressing this issue. Again, thanks you!