Skip to content

bug: tap click activates buttons without scrollEvents, but scrollEvents introduces perf issues #22030

@zrev2220

Description

@zrev2220

Bug Report

Ionic version:

[ ] 4.x
[x] 5.x

Current behavior:

When scrolling an ion-list with clickable ion-items (button="true"), the item the user touches in order to scroll plays its "activated" style or animation (i.e. ripple effect on Android, darkened background on iOS). This happens even if the user is not "clicking" on that item.

Expected behavior:

When scrolling the list, the touched item should not change in appearance (play the ripple effect or change the background). These styles should only activate when the user taps/clicks an item to select it.

Steps to reproduce:

  1. Create a basic Ionic app (ionic start)
  2. Add an ion-list to one of the pages containing enough ion-items to enable scrolling
  3. Scroll the list with the app running in a mobile-ish environment (i.e. emulated touch enabled via devtools in a browser, or run on a physical device)

Related code:

StackBlitz: https://stackblitz.com/edit/ionic-list-ripple-bug

Snippet from Angular template:

<ion-list>
  <ion-item *ngFor="let i of range(100)" button="true" detail="false">
    Item #{{i}}
  </ion-item>
</ion-list>

The range function is defined as follows:

range(n) {
  return Array.from(Array(n).keys());
}

Other information:

This bug seems similar/identical to that identified in #15752. That issue references 7f38d37 as fixing the problem, but since I can reproduce it in a recent Ionic version, it seems to have reappeared(?).

Ionic info:

Note: I created the above StackBlitz example by forking https://stackblitz.com/edit/ionic-v4-angular-tabs. That codebase does not run as-is via ionic serve or npm start, and ionic info fails with an error:

[WARN] You are not in an Ionic project directory. Project context may be missing.

To at least provide some useful ionic info output, I ran ionic init to make the directory an Ionic project. However, some Angular packages are still not installed (since StackBlitz magically makes things work), and the example may not be runnable locally without some additional installations and setup work.

[WARN] Error loading @ionic/angular-toolkit package.json: Error: Cannot find module '@ionic/angular-toolkit/package'

       Require stack:
       - <path to global node_modules>\@ionic\cli\lib\project\index.js
       - <path to global node_modules>\@ionic\cli\lib\index.js
       - <path to global node_modules>\@ionic\cli\index.js
       - <path to global node_modules>\@ionic\cli\bin\ionic
[WARN] Error loading @angular/cli package.json: Error: Cannot find module '@angular/cli/package'

       Require stack:
       - <path to global node_modules>\@ionic\cli\lib\project\index.js
       - <path to global node_modules>\@ionic\cli\lib\index.js
       - <path to global node_modules>\@ionic\cli\index.js
       - <path to global node_modules>\@ionic\cli\bin\ionic
[WARN] Error loading @angular-devkit/build-angular package.json: Error: Cannot find module
       '@angular-devkit/build-angular/package'

       Require stack:
       - <path to global node_modules>\@ionic\cli\lib\project\index.js
       - <path to global node_modules>\@ionic\cli\lib\index.js
       - <path to global node_modules>\@ionic\cli\index.js
       - <path to global node_modules>\@ionic\cli\bin\ionic

Ionic:

   Ionic CLI                     : 6.11.0
   Ionic Framework               : @ionic/angular 5.3.2
   @angular-devkit/build-angular : not installed
   @angular-devkit/schematics    : 10.1.0
   @angular/cli                  : not installed
   @ionic/angular-toolkit        : not installed

Utility:

   cordova-res : 0.15.1
   native-run  : 1.0.0

System:

   NodeJS : v14.4.0
   npm    : 6.14.5
   OS     : Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions