question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: `ion-reorder` complete() method moves injected Angular comments used by *ngFor

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

After the first item of a list is reordered, additional items are inserted at locations other than the bottom.

The root cause is that when doReorder calls ev.detail.complete(); Ionic’s DOM manipulation causes the Angular binding comment to move relative to the list items. New DOM elements are inserted by Angular at the location of this comment.

<!--bindings={
  "ng-reflect-ng-for-of": "Item 0,Item 1,Item 2,Item 3"
}-->

Expected Behavior

New items pushed onto the list array should be added to the bottom.

Specifically, the location of Angular’s comment should remain at the end of the items generated by ngFor after Ionic reorders the DOM elements.

Steps to Reproduce

  1. Use @ionic/angular.
  2. Create an ion-reorder-group with a list of items generated by ngFor.
  3. Drag the first item down (e.g. to the bottom of the list).
  4. Now add a new item to the array referenced by ngFor.

Code Reproduction URL

https://stackblitz.com/edit/ionic6-angular13-chauqs

Ionic Info

The StackBlitz is using Angular 13.3.1 and @ionic/angular 6.0.14, but the same behavior is present on 5.5

Additional Information

The workaround I’m using for now is to reject the reorder operation by calling ev.detail.complete(false);, so the DOM does not change, rely on Angular to synchronize the DOM with my array, and not have any animation on the bounce back.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sean-perkinscommented, Apr 6, 2022

@byronigoe thanks for reporting this issue. I am seeing the same behavior you describe.

The reorder logic is moving the Angular comment reference that Angular uses for injecting nodes added to the *ngFor. We will likely need to update our reorder logic so that it only tracks and moves actual HTML elements or nodes with a tag name.

We will capture this as a bug and prioritize in an upcoming sprint.

0reactions
ionitron-bot[bot]commented, May 8, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 2 dependency injection error on NgFor in dynamically ...
I've dynamically created an Angular 2 component using DynamicComponentLoader.loadAsRoot() , and am trying to give it a useful template ...
Read more >
Ionic Forum - Latest topics - RSSing.com
I'm trying to use the new ion-reorder-group and ion-reorder. I'd like to capture an event when a reordering occurs but I am not...
Read more >
How to Build an Ionic 5 Calendar with Modal & Customisation
In this post we will use one of the best calendar components for Ionic called ... Calendar event was clicked async onEventSelected(event) {...
Read more >
Incident Response - Hybrid Analysis
Not all malicious and suspicious indicators are displayed. Get your own cloud service or the full version to view all details. Malicious Indicators...
Read more >
Angular ng-content and Content Projection: A Complete Guide ...
So as you can see, we still had to use a couple of tricks to make this component look and behave as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found