Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column order for table layout in field interface is changed in the snapshot #20719

Open
Galaen opened this issue Dec 12, 2023 · 2 comments
Open

Comments

@Galaen
Copy link

Galaen commented Dec 12, 2023

Describe the Bug

I have a field "periods" (O2M) and I configure the "interface" of the field to use "table" as the Layout.
You can order your columns here :
image
But when you export this in a snapshot it dosen't keep the chosen order (seem alphabetical instead).
image

And once you re-import the snapshot the order is changed as in the snapshot.

It doesn't seem to me to be the expected behaviour.
At the moment, once the snapshot is created I have to edit the snapshot to change this order again

This comment seems to reference the same problem:
#19756 (comment)

To Reproduce

  • create 2 collections with fields
  • 1 collection field should be 02M and reference the other collection
  • when configuring this field go to "interface" and change the layout to "table"
  • add few fields and order them as you want (not alpha)
  • generate a snapshot (see the order not yours)
  • change something like adding a new column to force import to see a diff
  • apply the snapshot
  • you can now see the order changed in the interface (not the order you wanted)

Directus Version

v10.8.2

Hosting Strategy

Self-Hosted (Docker Image)

@arminfelke
Copy link

The same issue can also, for example, be observed with the toolbar of the WYSIWYG editor (v10.10.5, self-hosted (node)).
The actual order is lost when the snapshot is created. The toolbar buttons in the snaphost are sorted alphabetically.

@JohJonker
Copy link

Same for us: it seems all string arrays that are output in the schema get sorted by raw value. This has the knock-on effect of creating unnecessary diffs when calling the /schema/diff endpoint, since the internal snapshot used to compare against the incoming schema doesn't reflect the correct array order, meaning that a diff is created every time to try to "restore" it.

As far as I can see the automatic sorting behaviour is introduced by sortDeep in api/src/utils/get-snapshot.ts, i.e.:

if (isArray(raw)) {
   return sortBy(raw);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants