ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.93k stars 13.52k forks source link

bug: Ion-item-sliding option can be clicked for a moment after item is closed #22722

Closed mrSingh007 closed 1 year ago

mrSingh007 commented 3 years ago

'ion-item-sliding' 'option' is clickable even when slide is closed.

for example in the following is user click on same location where 'Lorem' button was displayed, after closing the slide, it will trigger 'unread' function.

 <ion-item-sliding>
    <ion-item>
      <ion-label>Item Options</ion-label>
      <ion-icon name="trash" (click)="ipsum()"></ion-icon>
    </ion-item>
    <ion-item-options side="end">
      <ion-item-option (click)="unread(item)">Lorem</ion-item-option>
    </ion-item-options>
  </ion-item-sliding>

Problem is that after sliding is closed it takes bit time to remove 'slide-active' classes. In this mean time when user click on item on same function, it get clicked on item option even item option is not visible.

Ionic version: ionic --version: 6.12.1

Expected behavior: After item sliding is closed the options should not be clickable. This should happen fast.

Steps to reproduce: From above code, Just slide to see 'Lorem' option. Now close the slide and click on same position where lorem option was displayed. (or on trash icon)

ionitron-bot[bot] commented 3 years ago

Thanks for the issue! This issue has been labeled as holiday triage. With the winter holidays quickly approaching, much of the Ionic Team will soon be taking time off. During this time, issue triaging and PR review will be delayed until the team begins to return. After this period, we will work to ensure that all new issues are properly triaged and that new PRs are reviewed.

In the meantime, please read our Winter Holiday Triage Guide for information on how to ensure that your issue is triaged correctly.

Thank you!

ionitron-bot[bot] commented 3 years ago

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please reproduce this issue in an Ionic starter application and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

For a guide on how to create a good reproduction, see our Contributing Guide.

mrSingh007 commented 3 years ago

@liamdebeasi Here is reproduction on Stackblitz https://stackblitz.com/edit/angular-ivy-p5wn6z?file=src/app/app.component.html and video https://drive.google.com/file/d/1qiSioSmwA6CMNcDMP1uf6cKj--80GArs

liamdebeasi commented 3 years ago

Thanks, I can reproduce the issue. Looks like this is due to a setTimeout of 600ms in the code: https://github.com/ionic-team/ionic-framework/blob/f81d18c6f9f1bce056afda1cac4cf6d6ace0a7ca/core/src/components/item-sliding/item-sliding.tsx#L361-L364.

mrSingh007 commented 3 years ago

@liamdebeasi any workaround for that?

kixes commented 2 years ago

It has been almost one year. Do we have a solution or version with a fix for this yet?

kixes commented 2 years ago

I have created a flexible workaround:

  handleSlideBtn(event, func, ...parmas) {
    const slider = event.target.parentNode.parentNode.querySelector('ion-item');
    if ( !!slider.style.transform ) {
      func.apply(this, parmas);
    }
  }

so basically add the $event from click to determine if the slider is open or not based on the transform style. Then pass in your function that you would be calling for that button as the second parameter. Then pass in whatever parameters you would normally pass to the function. So in example:

<ion-item-option (click)="myFunc(parm1, parm2, parm3)">

would become:

<ion-item-option (click)="handleSlideBtn($event, myFunc, parm1, parm2, parm3)">

Note that this still doesn't run the click event on the ion-item if it exists but it does prevent the buttons from running while the slider is closed. The primary weak point in the handleSideBtn function is the slider variable, I wrote this under the assumption that this guide is followed strictly https://ionicframework.com/docs/api/item-sliding with no extra elements.

strarsis commented 2 years ago

@kixes: Does this issue still exist in Ionic v6?

liamdebeasi commented 1 year ago

Thanks for the issue. This has been resolved via https://github.com/ionic-team/ionic-framework/pull/27829, and a fix will be available in an upcoming release of Ionic Framework.

ionitron-bot[bot] commented 1 year ago

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.