Restrict drag to inside properties array only
I need to allow user to arrange order of properties just inside one array but prevent dragging to another node. Is there a way to accomplish this ? I used validation with no problem, but preventing would be more user frendly. On pic example, one layers property is dragged outside layers array to root, that is what I want to prevent and restrict dragging only to layers array.
That is an interesting idea, I see what you mean.
Thinking aloud here: I think this should be a configuration option, since this restriction is not always what you want. Or would it make sense to, say, when dragging, restrict dragging outside by default, and when having the Ctrl key down, allow dragging outside?
Maybe to link restriction to json schema ?
That's a good idea!
We could implement the following behavior:
- Create an option "dragInsideOnly", which can be set to
true,false - When the option is not specified, limit dragging to inside only when a JSON schema is defined, and do not limit dragging otherwise
Anyone interested in implemented this feature?
+1
Just a small note that It would be nice to have ability to restrict drag of elements in current level no matter if it's elements inside of array or objects inside of parent object. I'm really suffering from it as in my current project I need somehow to prevent drag of child objects to top level.
I just had a short look at the code, and it turns out this is quite easy to implement. Working on it.
I've published this new option limitDragging in v9.0.0.
@keshon and @AlenKelemen can you give it a try?
I've published this new option
limitDragginginv9.0.0.@keshon and @AlenKelemen can you give it a try?
@josdejong I tested and it works great. Thank you very much!
Heads up that limitDragging is not declared in the type file so it can't be used when using typescript
so it can't be used when using typescript
@gigiskarlett you can always work around that with @ts-ignore or something like that.
It would be great if you or someone else can create a PR at DefinitelyTyped to add this missing option limitDragging in the TypeScript definitions. Anyone able to help out?
so it can't be used when using typescript
@gigiskarlett you can always work around that with
@ts-ignoreor something like that.It would be great if you or someone else can create a PR at DefinitelyTyped to add this missing option
limitDraggingin the TypeScript definitions. Anyone able to help out?
I added the type definition to DefinitelyTyped and it has been merged so this shouldn't be a problem moving forward. Thanks for doing this library 🙏🏽
Heee that's awesome, thanks Gigi 👍