Skip to content

Ionic 4 ion-item-sliding stops sliding after list is updated #16824

Closed

Description

@OJ7

Bug Report

Ionic version:

[x] 4.x

Current behavior:

Same bug as reported earlier but that does not fix the core issue but rather uses a workaround.

Expected behavior:

  • After the list is refreshed/updated, the elements should still be slide-able.

Steps to reproduce:

  • Create an <ion-list> of <ion-item-sliding> elements
  • Open the slide menu of one of the elements
  • Have the app update the list in the background (reassign the list variable)
  • The list refreshes and the elements are not able to use the slide gesture.

Related code:

// HTML
  <ion-list>
    <ion-item-sliding *ngFor='let a of list'>
      <ion-item>
        <ion-text>{{a}}</ion-text>
      </ion-item>

      <ion-item-options side="end">
        <ion-item-option color="danger">
          <ion-icon name="trash"></ion-icon>
          Delete
        </ion-item-option>
      </ion-item-options>
    </ion-item-sliding>
  </ion-list>

// COMPONENT/PAGE
  public list: string[] = ['A', 'B', 'C'];
  
  // use a short delay to update list after opening up the slide item
  this.list = ['A', 'B', 'C', 'D'];

Other information:

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.5.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-rc.0
   @angular-devkit/build-angular : 0.10.7
   @angular-devkit/schematics    : 7.1.3
   @angular/cli                  : 7.1.3
   @ionic/angular-toolkit        : 1.2.0

System:

   NodeJS : v10.12.0 (/usr/local/Cellar/node/10.12.0/bin/node)
   npm    : 6.4.1
   OS     : macOS Mojave

Activity

  1. Majed93 commented on Dec 19, 2018

    @Majed93

    You could try the workaround from here

    #15486 (comment)

    This issue is when an item is removed however but worth a try.

  2. OJ7 commented on Dec 20, 2018

    @OJ7
    Author

    Thanks, I can likely use that. However the thing is I don't want to (and shouldn't have to) close the sliding items whenever the list is updated.

    I have a list that is frequently being updated and would like the item to stay in the "open slide out" state if the user performed the action, even if there is a modification to the list.

    I've noticed the same thing happens regardless of whether there is an addition or removal to the list. If the list is assigned to an equivalent list, the same issue occurs.

  3. dylanvdmerwe commented on Jan 9, 2019

    @dylanvdmerwe
    Contributor

    A work around is here: #15486 (comment)

    Verified that the work around does do the trick. But it should not be necessary.

    
    Ionic:
    
       ionic (Ionic CLI)             : 4.6.0 (C:\Users\dylan\AppData\Roaming\npm\node_modules\ionic)
       Ionic Framework               : @ionic/angular 4.0.0-rc.0
       @angular-devkit/build-angular : 0.11.4
       @angular-devkit/schematics    : 7.1.4
       @angular/cli                  : 7.1.4
       @ionic/angular-toolkit        : 1.2.2
    
    Cordova:
    
       cordova (Cordova CLI) : 8.1.2 ([email protected])
       Cordova Platforms     : not available
       Cordova Plugins       : not available
    
    System:
    
       NodeJS : v10.14.1 (C:\Program Files\nodejs\node.exe)
       npm    : 6.4.1
       OS     : Windows 10
    
  4. cfguimaraes commented on Jan 20, 2019

    @cfguimaraes

    Hi all, I've this same issue.

    I've created 2 options for sliding, and when one option is selected (click) I call an AlertController to show some options, like edit the item. After edit, and confirm changes in AlertController I update the array used to display the ion-list, after this cannot slide, until app is reopened.

    Is there something I can help?

  5. pimol commented on Jan 23, 2019

    @pimol

    I want add to that cfguimaraes noted: if I modify the item without add or remove element, slide does not disappear but slide doesn't not go back in no sliding position despite list has been updated. To be more clear, AFTER the update the screen remain as the image

    immagine

  6. mautematico commented on Jan 29, 2019

    @mautematico

    Same issue here, with a variant:

    I am iterating over a Map like this (Tickets.newTicket is a Map<Object, number>) :

      <ion-list>
        <ion-item-sliding *ngFor="let row of Tickets.newTicket | keyvalue">
          <ion-item-options side="end">
            <ion-item-option (click)="plusOne(row.key)" color="ligth">
              <ion-icon slot="icon-only" name="add-circle" color="success"></ion-icon>
            </ion-item-option>
          </ion-item-options>
        </ion-item-sliding>
      </ion-list>
    

    plusOne() takes Map key and increments it (Map.prototype.set()) by one. At this point, I think the full list gets repainted and when it comes back it can't slide.

    P.S. here, the user should be able to press plusOne(key) as many times as desired, it's not like a 'delete button', but a 'I want more of this' one.

  7. OJ7 commented on Feb 19, 2019

    @OJ7
    Author

    Ionic has pushed a fix for a similar issue that will be released in 4.1.0. I will test it out after it is released to see if it fixes this issue too.

  8. OJ7 commented on Feb 20, 2019

    @OJ7
    Author

    Just tried with the 4.0.2 release which contains the above mentioned fix. The sliding items don't appear to be getting stuck after updating the list. It does seem to automatically close the sliding menu when the list is updated though, similar to the workaround mentioned at the beginning of this thread.

    I'll close this issue as it the fix works for me. If anyone is not satisfied with this, they can open up a new issue.

  9. ionitron-bot commented on Mar 22, 2019

    @ionitron-bot

    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.

  10. locked and limited conversation to collaborators on Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: core

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions