Open rcarcasson opened 4 months ago
Any reason not to use an Array instead of an Object for ordered values? Property order in javascript objects isn't generally guaranteed
I don't know why it was implemented using an object, but it has worked like this for years. What we want is for it not to sort the object when any modification is saved. Changing the object to an array would mean modifying the front that uses this information and modifying the entire structure of the collections that use this current format
I'm assuming it's caused by the fact that the JSON interface uses JSON.stringify()
to format the values when the form is rendered, which combined with JS' non-guaranteed order causes it to be resorted.
I tried to figure out why this happen without results so finally I change the format of the data to an array with the object on it and it keeps the elements without sort them
These help me to keep the order of the elements
Describe the Bug
I have a collection with a JSON field type on it with a simple structure:
The issue: I want a specific order to each element, but it doesn't matter where i put the element, every time I save the record Directus sort the elements by each text length:
I want:
But Directus sort the element:
How I can avoid this behaviour?
To Reproduce
Create a JSON field type on any collection as JSON type
Directus Version
v10.6.3
Hosting Strategy
Self-Hosted (Docker Image)
Database
No response