You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
provided on calling DragulaModule.forRoot() imports: [DragulaModule.forRoot()]
As such it is easy to get inject the wrong instance of the DragulaService leading to incorrect behaviour. In my application I have a service (providedIn: Root) that injects the DragulaService. However, because it is providedIn root, since the v3 update it is now getting a different instance of the DragulaService to that injected into the DragulaDirective. As such calls of createGroup made in my root service are being ignored.
*** Expected:
importing DragulaModule does not provide an instance of the DragulaService and instead the DragulaService is either provided by providedIn: root or DragulaModule.forRoot(). My preferred solution would be to remove the forRoot and rely solely on providedIn: root, but this would be a breaking change.
Versions (required)
Please state which versions of the following packages you have installed:
@angular/core: 14.2.12
ng2-dragula: 3.2.0
The text was updated successfully, but these errors were encountered:
I can confirm that I run into the same issue and it's definitely BUG. You should either provide DragulaService in root and remove it from providers list in DragulaModule and remove forRoot function or keep forRoot function and remove it from providers list in DragulaModule and remove providedIn from DragulaService service decorator. I tried fixes locally and they were working as expected.
I am dynamically creating the inner components which should use the same dragulaService, but it seems that it is different instance.
Check the console where is logged for each dynamic component and for root component:
container name, just for identification
groups within injected dragulaService instance (should be always 'wysiwyg')
containers (or their css classes) of drake for group called 'wysiwyg'
As you can see, each dynamic component has only containers inside themselves, so it is not connected to each other and to root container.
Compare it with old version where I do the same dynamic loading (just in a bit different way because of angular 9) and in console all the containers are connected. And it is because there is only 1 instance od dragulaService accross the whole project. https://stackblitz.com/edit/angular-9-ng2-dragula-211
Please, check it. I think the solutions suggested above should resolve this issue.
REQUIRED: Before filing a bug report
Change each
[ ]
to[x]
when you have done it.[bug report]
ng2-dragula
issues for related problems, including closed issues.ng2-dragula
.Describe the bug (required)
With v3 of this library, the DragulaService is provided multiple times instead of just when importing DragulaModule.forRoot().
providedIn: root
https://github.com/valor-software/ng2-dragula/pull/1044/files#diff-845f2a393c0ade2f75831cff246267c8b1c96691d81d2d710c47f20eb14ef6d9R31imports: [DragulaModule]
https://github.com/valor-software/ng2-dragula/pull/1044/files#diff-77b8912947381f081ed7f9efbc418716a1dcdfac9c5ebc2d5e6539cad507878fR8imports: [DragulaModule.forRoot()]
As such it is easy to get inject the wrong instance of the DragulaService leading to incorrect behaviour. In my application I have a service (providedIn: Root) that injects the DragulaService. However, because it is providedIn root, since the v3 update it is now getting a different instance of the DragulaService to that injected into the DragulaDirective. As such calls of createGroup made in my root service are being ignored.
*** Expected:
importing DragulaModule does not provide an instance of the DragulaService and instead the DragulaService is either provided by
providedIn: root
or DragulaModule.forRoot(). My preferred solution would be to remove the forRoot and rely solely onprovidedIn: root
, but this would be a breaking change.Versions (required)
Please state which versions of the following packages you have installed:
@angular/core
: 14.2.12ng2-dragula
: 3.2.0The text was updated successfully, but these errors were encountered: