Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mrSingh007 opened this issue Dec 28, 2020 · 10 comments · Fixed by #27829
Closed

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

mrSingh007 opened this issue Dec 28, 2020 · 10 comments · Fixed by #27829
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@mrSingh007
Copy link

mrSingh007 commented Dec 28, 2020

'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)
- it will trigger 'unread' function.

@ionitron-bot ionitron-bot bot added the holiday triage issues that were created during holiday period label Dec 28, 2020
@ionitron-bot
Copy link

ionitron-bot bot commented Dec 28, 2020

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!

@liamdebeasi liamdebeasi added the ionitron: needs reproduction a code reproduction is needed from the issue author label Dec 28, 2020
@ionitron-bot
Copy link

ionitron-bot bot commented Dec 28, 2020

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.

@ionitron-bot ionitron-bot bot removed the holiday triage issues that were created during holiday period label Dec 28, 2020
@mrSingh007
Copy link
Author

@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report and removed ionitron: needs reproduction a code reproduction is needed from the issue author labels Jan 6, 2021
@liamdebeasi liamdebeasi changed the title bug: Ion-item-sliding option is clickable even slide is closed bug: Ion-item-sliding option can be clicked for a moment after item is closed Jan 6, 2021
@liamdebeasi
Copy link
Contributor

Thanks, I can reproduce the issue. Looks like this is due to a setTimeout of 600ms in the code:

this.tmr = setTimeout(() => {
this.state = SlidingState.Disabled;
this.tmr = undefined;
}, 600) as any;
.

@mrSingh007
Copy link
Author

@liamdebeasi any workaround for that?

@kixes
Copy link

kixes commented Nov 6, 2021

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

@kixes
Copy link

kixes commented Nov 11, 2021

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
Copy link

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

@liamdebeasi liamdebeasi added type: bug a confirmed bug report and removed type: bug a confirmed bug report labels Apr 21, 2023
github-merge-queue bot pushed a commit that referenced this issue Jul 20, 2023
Issue number: resolves #22722

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

Item Sliding Options are not disabled until after a 600ms timeout. This
timeout exists to allow the close transition to complete. Without the
timeout, the item sliding options disappear without a transition. I
explored waiting for the `transitionend` event instead of the
`setTimeout`, but the bug persisted.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- If an item sliding is closing then we add a class to the host. This
class disables pointer events on all `ion-item-options` children so the
buttons cannot be accidentally tapped while closing. This class is then
removed after the 600ms timeout.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #27829, and a fix will be available in an upcoming release of Ionic Framework.

brandyscarney pushed a commit that referenced this issue Jul 26, 2023
Issue number: resolves #22722

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

Item Sliding Options are not disabled until after a 600ms timeout. This
timeout exists to allow the close transition to complete. Without the
timeout, the item sliding options disappear without a transition. I
explored waiting for the `transitionend` event instead of the
`setTimeout`, but the bug persisted.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- If an item sliding is closing then we add a class to the host. This
class disables pointer events on all `ion-item-options` children so the
buttons cannot be accidentally tapped while closing. This class is then
removed after the 600ms timeout.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
@ionitron-bot
Copy link

ionitron-bot bot commented Aug 19, 2023

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Aug 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants