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

Enable re-ordering of properties #68

Closed
SanderKok01 opened this issue Jun 11, 2024 · 5 comments · Fixed by #79
Closed

Enable re-ordering of properties #68

SanderKok01 opened this issue Jun 11, 2024 · 5 comments · Fixed by #79
Assignees
Labels
user request Requested by user

Comments

@SanderKok01
Copy link

Hello,

I'd like to be able to re-order properties. Drag and drop one above the other.
Is this possible?

@CarlosNZ
Copy link
Owner

CarlosNZ commented Jun 12, 2024

This is not possible right now, and would probably add quite a bit of complexity to the component, so I'd have to carefully consider the best way to implement it.

It's a bit tricky, because strictly speaking object properties don't have an "order", and it's only through JS implementation details that key order is mostly preserved at all. (For example, if you save a JSON field as binary in a Postgres database, the order is completely ignored, and will be alphabetized on next read).

For now, the only way to change the order (other than deleting and re-adding keys) is to edit the JSON directly and move it around as text:

Screenshot 2024-06-12 at 5 50 20 PM

@CarlosNZ
Copy link
Owner

I've created an issue to consider key ordering more generally, so will definitely be thinking about it further: #73

@CarlosNZ CarlosNZ added the user request Requested by user label Jun 15, 2024
@CarlosNZ CarlosNZ self-assigned this Jun 18, 2024
@CarlosNZ
Copy link
Owner

@SanderKok01, I've started playing round with a basic drag-n-drop. I should have something for you to try out next week some time. :)

@CarlosNZ
Copy link
Owner

CarlosNZ commented Jun 23, 2024

You can now do basic drag-n-drop in v1.13.1: https://www.npmjs.com/package/json-edit-react/v/1.13.1

Let me know how it goes :)

@SanderKok01
Copy link
Author

Amazing, thank you!

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

Successfully merging a pull request may close this issue.

2 participants