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.

[Ionic V4.0.0-beta.7] [ion-item-sliding] Sliding not working after empty an element in array

See original GitHub issue

Bug Report

Ionic Info Run ionic info from a terminal/cmd prompt and paste the output below.

Ionic:

   ionic (Ionic CLI)          : 4.1.2 (C:\Users\fkrishna\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.7
   @angular-devkit/core       : 0.7.5
   @angular-devkit/schematics : 0.7.5
   @angular/cli               : 6.1.5
   @ionic/ng-toolkit          : 1.0.8
   @ionic/schematics-angular  : 1.0.6

System:

   NodeJS : v8.11.3 (C:\Program Files\nodejs\node.exe)
   npm    : 5.6.0
   OS     : Windows 10

Describe the Bug I created an array of 3 elements and i used the <ngFor> and the <ion-item-sliding">directive to show a list of sliding item. Each item has a remove button to remove the target element, but after removing one element the sliding stop working for the remaining items

Steps to Reproduce Steps to reproduce the behavior:

  1. Go to ‘…’
  2. Click on ‘…’
  3. Scroll down to ‘…’
  4. See error

Related Code

<ion-content>
  <ion-list>
    <ion-item-sliding *ngFor="let n of numbers; index as i">
      <ion-item>
        {{ n }}
      </ion-item>
      <ion-item-options>
        <ion-item-option " (click)="remove(i)">Delete</ion-item-option>
      </ion-item-options>
    </ion-item-sliding>
  </ion-list>
numbers = ['1','2','3'];
  constructor() {}
  remove(i) {
    this.numbers.splice(i, 1);
}

Expected Behavior the sliding is suppose to work correctly for each items even after removing an element

Additional Context List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, screenshots, OS if applicable, etc.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:30 (5 by maintainers)

github_iconTop GitHub Comments

39reactions
jcollingscommented, Sep 10, 2018

Also had the same issue, with a dynamic list of elements, deleting an item with the <ion-item-sliding> component, then refreshing the elements cause it not to be able to delete any other elements until a refresh.

After digging around i noticed that without the refresh of elements it worked fine, looking at the docs there is a method to close all sliding items on the item or on the list. using this fixed the issue.

  1. Giving the ion-list an id #dynamicList
  2. Accessing that list by the id @ViewChild('dynamicList') dynamicList;
  3. On clicking of <ion-item-option> triggering the dynamicList.closeSlidingItems() before deleting the record.

Hope this helps in the meantime, i am new to angular so hopefully i am not doing anything that stupid.

35reactions
peterpeterparkercommented, Sep 10, 2018

not all heroes wear capes, thx @jcollings for the solution!

html:

 <ion-list #slidingList>
   <ion-item-sliding>
     <ion-item-options side="end">
        <ion-item-option (click)="delete()">
        </ion-item-option>
     </ion-item-options>
   </ion-item-sliding>
 </ion-list>

ts:

 import {List} from '@ionic/angular';

 @ViewChild('slidingList') slidingList: List;
 
 async delete() {
   // something
   await this.slidingList.closeSlidingItems();
 }
Read more comments on GitHub >

github_iconTop Results From Across the Web

[Ionic V4.0.0-beta.7] [ion-item-sliding] Sliding not ... - GitHub
[Ionic V4.0.0-beta.7] [ion-item-sliding] Sliding not working after empty an element in array #15486.
Read more >
[Ionic V4.0.0-beta.7] [ion-item-sliding] Sliding not working after empty ...
[Ionic V4.0.0-beta.7] [ion-item-sliding] Sliding not working after empty an element in array.
Read more >
Ion-item-sliding not working on phone (ionic v4)
Using version 4.0.0-beta.7, once deployed in Android or iOS, the sliding works fine initially, but after a while it is not possible to...
Read more >
Is there a way to find out if the "ion-item-sliding" is back in idle ...
As soon as I release the item and it goes back into the idle position, which should be 0, the (ionDrag) stops emitting...
Read more >
Vertical Scroll In Storybook Is Not Accurate - ADocLib
Storybook CodeSandbox Not specifying a vertical or horizontal alignment will ... [Ionic V4.0.0beta.7] [ionitemsliding] Sliding not working after empty an.
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