Comments (6)
Hi @kuba-010
sorry for a late answer. I think the reason is in the object you pass to the group
property. The only thing I tested this was a string, so I can't really tell you what is the source of the problem here.
Did you manage to find a solution on that?
from ngx-sortablejs.
Nope, sadly not. I think it's to do with the source library and the set timeouts. I managed to force it to not error by rebuilding the source list after a timeout. Not a solution, or even a workaround really, but I think it shows something is happening to the source list.
It's pretty easy to replicate, create a new cli project, add sortablejs then stick this in as the html:
<h2>Copy From List</h2>
<div class="sortlist" [sortablejs]="items" [sortablejsOptions]="sourceOptions">
<div *ngFor="let item of items">{{item.name}}</div>
</div>
<h2>Copy To List</h2>
<div class="sortlist" [sortablejs]="formula" [sortablejsOptions]="targetOptions">
<div *ngFor="let item of formula">{{item.name}}</div>
</div>
then in the component:
sourceOptions:SortablejsOptions={group: { name: 'formula', pull: 'clone', put: false }, sort:false }
targetOptions:SortablejsOptions={group: { name: 'formula' }}
items=[
{name:"Item 1"},{name:"Item 2"},{name:"Item 3"},{name:"Item 4"},
];
formula=[];
from ngx-sortablejs.
Hi!
I was having the same problem, and I thought that it could be an internal problem of the library while updating the arrays associated to the lists, so I tried not to use '[sortablejs]="items"' and use only 'sortable' and update the array manually by capturing an event. However, I couldn't get it working, when I pull an item from the source list, it gets duplicated in the destination container, but the strange thing is that, internally, the destination array is correct.
Basically, what I did in the HTML template file was:
<!-- Source list -->
<div id="luid1" class="card-collapse">
<div class="list-group" sortablejs [sortablejsOptions]="opt_uid1">
<a href="#" class="list-group-item list-group-item-action"
*ngFor="let uid of uid1">
{{uid}}
</a>
</div>
</div>
<!-- Destination list -->
<div id="luid2" class="card-collapse">
<div class="list-group" sortablejs [sortablejsOptions]="opt_uid2">
<a href="#" class="list-group-item list-group-item-action"
*ngFor="let uid of uid2">
{{uid}}
</a>
</div>
</div>
And, on the component TS file:
uid1 = [ 1, 2, 3 ];
uid2 = [ 4, 5, 6 ];
opt_uid1: SortablejsOptions = {
sort: false,
dataIdAttr: 'uid1',
group: {
name: 'uid',
pull: 'clone',
put: false
},
animation: 150
};
opt_uid2: SortablejsOptions = {
sort: true,
dataIdAttr: 'uid2',
group: {
name: 'uid',
pull: true,
put: true
},
animation: 150,
onAdd: (evt) => {
// Manually update the destination list
let sourceIdx = evt.oldIndex;
let destinyIdx = evt.newIndex;
// We get the item from the source list (this.uid1)
let item = this.uid1[sourceIdx];
console.log(this.uid2);
this.uid2.splice(destinyIdx, 0, item); // We add the item to the list. It works fine, but visually we
console.log(this.uid2); // have 2 copies
}
};
Any ideas on this? Thanks in advance,
from ngx-sortablejs.
Hi @smnbbrv, has there been any progress on this? As @kuba-010 has mentioned, this happens in the simplest case of cloning - nothing weird going on so it should really be addressed. If there is no solution or workaround for this I will have to move away from using SortableJS which is a shame...
from ngx-sortablejs.
Hi @sarawoods
I've become a happy father with all the consequences :) So I would not expect that much activity from my side in the closest future. Luckily, we are on github where everybody can make contributions - just find the problem, change the code and make a pull request.
from ngx-sortablejs.
Fixed with 2.3.1, see https://smnbbrv.github.io/angular-sortablejs-demo/multiple-lists
from ngx-sortablejs.
Related Issues (20)
- Issue with dragging last item in last row HOT 1
- Mobile reordering is spotty
- Support Angular 12 HOT 9
- Plugins swap not working, please help me to custom add swap function.
- Angular 6 issue compatibility HOT 3
- Does not work with Angular Material Grid List
- Unmount Plugins on ngDestroy HOT 1
- Support Angular 13 HOT 18
- Module '"ngx-sortablejs"' has no exported member 'SortablejsOptions'.ts in Angular 12 HOT 4
- Publish an Ivy distribution HOT 1
- Unable to evaluate this expression statically HOT 2
- Incorrect order after adding an element in array HOT 3
- Escape to cancel drag/drop operation
- this libray found not support Anglar13 any body Idia about that HOT 11
- Generating browser application bundles (phase: setup)...Processing legacy "View Engine" libraries
- Make hold to start dragging
- How to set a boundary to the drag operation
- npmjs does not show any helpful text for the package
- Angular 11 simple sorting not working
- Compatibility with the Ivy view engine HOT 18
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-sortablejs.