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
{{ message }}
Repository navigation
[Ionic V4.0.0-beta.7] [ion-item-sliding] Sliding not working after empty an element in array #15486
Describe the Bug
I created an array of 3 elements and i used the 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:
Go to '...'
Click on '....'
Scroll down to '....'
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>
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.
changed the title [-][Ionic V4.1.2] [ion-item-sliding] Slide not working after empty an element in array[/-][+][Ionic V4.1.2] [ion-item-sliding] Sliding not working after empty an element in array[/+]on Sep 6, 2018
changed the title [-][Ionic V4.1.2] [ion-item-sliding] Sliding not working after empty an element in array[/-][+][Ionic V4.0.0-beta.7] [ion-item-sliding] Sliding not working after empty an element in array[/+]on Sep 6, 2018
Funny, just landed on that problem too, could confirm, if I delete with an action on item of the sliding list, the remaining items could not be slided anymore
Also had the same issue, with a dynamic list of elements, deleting an item with the 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.
Giving the ion-list an id #dynamicList
Accessing that list by the id @ViewChild('dynamicList') dynamicList;
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.
Reacted by Quynh Orange, Nuno Costa, Franco, tony, diazenal, Rafael Kraut, Cristian Rivas, Alejandro Torres Roa, Raul Ruiz Barea, Laurent and 15 more
Reacted by David Dal Busco, dev-sushant1992, tony, Rafael Kraut, Cristian Rivas, Prashanth Vijayendra, Kuljeet Singh Kakkar, Taron, onesbasket and Rey Columna
I found that another workaround is to pass the reference to the ItemSliding to the delete method and then just closing that one item before deleting the list item:
async deleteItem(slidingItem: ItemSliding, item: Item) {
slidingItem.close(); // <-- this is the important bit!
await this.itemService.deleteItem(item);
}
Reacted by houxy, Jaballi aymen, Cristian Rivas, Marcel Kipp, jaguileram, Bernie, Andrii Bilozor, katzenjunge, Eric, Stefan and 8 more
Have tried playing around with this issue and found that in my case the culprit for Ion Item Slider become unresponsive was that whenever the view was getting changed the sliding options were not getting closed. So I did the following thing & it worked perfectly:
This bug still exist in 4.0.0-rc.2.
I use a ion-item-sliding inside virtual-scroll, so I can't use List.closeSlidingItems().
If I don't close a item sliding and leave the view using back button or something, then the item sliding stop working next time at all. I can't use (click) event in this case because I open the sliding and just leave. There is no change to catch (click) event.
Another workaround. It works for me.
in .html
<ion-item-sliding>....</ion-item-sliding>
in .ts
import { IonItemSliding } from '@ionic/angular';
@ViewChild(IonItemSliding) itemSliding: IonItemSliding;
ionViewWillLeave() {
setTimeout(() => { this.itemSliding.closeOpened(); }, 500);
}
Thanks for this issue! This has been merged in by PR #17492. It will be in the next release: 4.1.0. Please let us know if you are still seeing problems after that.
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.
Activity
[-][Ionic V4.1.2] [ion-item-sliding] Slide not working after empty an element in array[/-][+][Ionic V4.1.2] [ion-item-sliding] Sliding not working after empty an element in array[/+][-][Ionic V4.1.2] [ion-item-sliding] Sliding not working after empty an element in array[/-][+][Ionic V4.0.0-beta.7] [ion-item-sliding] Sliding not working after empty an element in array[/+]quynh-ng commentedon Sep 7, 2018
I got the same issue.
By the way, the sliding items are not working after delete one, need to reload the app
Majed93 commentedon Sep 7, 2018
@quynh-ng I have the same issue, i've had to downgrade to beta.5 :(
peterpeterparker commentedon Sep 7, 2018
Funny, just landed on that problem too, could confirm, if I delete with an action on item of the sliding list, the remaining items could not be slided anymore
p.s.: in beta.8 it's the case too
fkrishna commentedon Sep 8, 2018
@quynh-ng same -_-
jcollings commentedon Sep 10, 2018
Also had the same issue, with a dynamic list of elements, deleting an item with the 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.
#dynamicList@ViewChild('dynamicList') dynamicList;<ion-item-option>triggering thedynamicList.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.
peterpeterparker commentedon Sep 10, 2018
not all heroes wear capes, thx @jcollings for the solution!
html:
ts:
Anthony2539 commentedon Sep 19, 2018
@peterpeterparker it works fine but is it a solution or a workaround ?
peterpeterparker commentedon Sep 19, 2018
@Anthony2539 probably a bit of both 😜
I don't know if it's a feature request or a bug
Some commit regarding slidings have been made recently I think, so maybe the problem is/will disappear
Anyhow, let's say that workaround works and won't arm my app I guess
Majed93 commentedon Sep 19, 2018
I'd say it's more a bug since i had to downgrade to get my e2e tests to pass again
netsesame2 commentedon Oct 8, 2018
This issue is obviously a bug. Remove an item should not need to close it before deleting, it's funny.
DanielKlier commentedon Oct 19, 2018
I found that another workaround is to pass the reference to the ItemSliding to the delete method and then just closing that one item before deleting the list item:
HTML:
TS:
yixiaohou commentedon Oct 19, 2018
@mimacom-klier Thank you very much for solving my problem perfectly.
11 remaining items
kuljeetsingh31 commentedon Dec 30, 2018
Hi,
Facing the below issue:
Issue:
Ion Item Sliding works only for first time. It stops responding when I slide the ion-item, then go to another page & come back.
Tried the work around suggested by @jcollings. Tried closing all ion item sliding when leaving the view as follows:
but didn't work.
My slider code is as follows:
Have tried with latest ionic version 4.0.0-rc.0. The issue still exists.
kuljeetsingh31 commentedon Dec 30, 2018
Hi,
Have tried playing around with this issue and found that in my case the culprit for Ion Item Slider become unresponsive was that whenever the view was getting changed the sliding options were not getting closed. So I did the following thing & it worked perfectly:
Many thanks to @jcollings.
elepetit commentedon Jan 6, 2019
I've donne this :
in .html
works perfectly
Many thanks to @jcollings.
amritaramnauth commentedon Jan 8, 2019
Can confirm that the issue still exists with 4.0.0-rc.0.
jkeczan commentedon Jan 19, 2019
Can confirm this exists in 4.0.0-rc.1 as well
pos7hink commentedon Jan 21, 2019
This bug still exist in 4.0.0-rc.2.
I use a ion-item-sliding inside virtual-scroll, so I can't use List.closeSlidingItems().
If I don't close a item sliding and leave the view using back button or something, then the item sliding stop working next time at all. I can't use (click) event in this case because I open the sliding and just leave. There is no change to catch (click) event.
Another workaround. It works for me.
norbertbede commentedon Jan 26, 2019
Dear Brandy,
@brandyscarney can you take a look ? we are in migration phase to v4 and i would like to hear ionic-team opinion. Looks me important issue.
big thanks.
norbert
brandyscarney commentedon Jan 28, 2019
Thanks for tagging me! I added it to our project board to look into.
@manucorporat @mhartington @paulstelzer
liamdebeasi commentedon Feb 14, 2019
Thanks for this issue! This has been merged in by PR #17492. It will be in the next release:
4.1.0. Please let us know if you are still seeing problems after that.ionitron-bot commentedon Mar 16, 2019
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.