-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v7.x
Current Behavior
When ion-item-sliding is rendered asynchronously, and the inner ion-item has been rendered via ng-template composition, sliding items fail to open when calling item.open() until they have been manually opened via the gesture.
Note that the contents of the sliding item are NOT rendered asyncronously -- This occurs when the ion-item-sliding itself is rendered asyncronously, in combination with the use of ng-template to contain the ion-item inside.
Please see the following video, where only items in the first group open on click:
https://user-images.githubusercontent.com/362329/226695190-36cb33d3-7aac-49f0-8f4a-118eab7f7b1e.mov
The issue occurs because this.item is null when open() is called on the sliding item instances rendered after the initial group. The function returns/aborts and the item is not opened:
/**
* Open the sliding item.
*
* @param side The side of the options to open. If a side is not provided, it will open the first set of options it finds within the item.
*/
@Method()
async open(side: Side | undefined) {
if (this.item === null) {
return;
}
Expected Behavior
Sliding items should open when item.open() is called in this scenario. This use-case is important, because using ng-template is a core part of Angular template composition and reduction of boilerplate/duplicate code within pages or components, and rendering additional items on a delay (or something like a paginator), is critical for rendering and page-load performance optimization.
Steps to Reproduce
- Run sample app.
- Click items in first group - they will open
- Click items in any group rendered thereafter in the list - they will NOT open
- Slide one of the non-opening items manually - it will open
- Close that item
- Click that item again - it will open
Code Reproduction URL
https://github.com/lincolnthree/ionic-issue-item-sliding-open
Ionic Info
Ionic:
Ionic CLI : 6.20.3 (/Users/lincoln/.nvm/versions/node/v16.14.0/lib/node_modules/@ionic/cli)
Ionic Framework : not installed
@angular-devkit/build-angular : 15.2.4
@angular-devkit/schematics : 15.2.4
@angular/cli : 15.2.4
@ionic/angular-toolkit : 8.0.0
Capacitor:
Capacitor CLI : 4.7.1
@capacitor/android : not installed
@capacitor/core : 4.7.1
@capacitor/ios : not installed
Utility:
cordova-res : not installed globally
native-run : 1.7.2
System:
NodeJS : v16.14.0 (/Users/lincoln/.nvm/versions/node/v16.14.0/bin/node)
npm : 8.3.1
OS : macOS
Additional Information
No response