ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: ion-item-sliding should close automatically when clicking anywhere in the content

Open q962 opened this issue 1 year ago • 5 comments

Prerequisites

Describe the Feature Request

auto close sliding

Describe the Use Case

When the user swipes an item, it will remain open unless manually closed.

Ideal logic: automatically close when the current item loses focus

Describe Preferred Solution

No response

Describe Alternatives

No response

Related Code

No response

Additional Information

The most convenient way

window.addEventListener("click", (el) => {
  let parent: HTMLElement | any = el.target;

  while (parent) {
    if (parent == list.value.$el) {
      return;
    }

    parent = parent.parentElement;
  }

  list.value.$el.closeSlidingItems();
});

In fact, when switching the background, it should also trigger auto close.

q962 avatar May 15 '24 14:05 q962

Could you please provide a code example that demonstrates the issue you're experiencing and what you expect to happen? You can use one of the demos in our documentation by clicking the lightning icon to open it in StackBlitz, then fork and update it with your code sample. Additionally, please provide steps for us to follow to understand the problem and what the expected outcome is. Thank you!

brandyscarney avatar May 31 '24 16:05 brandyscarney

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[bot] avatar May 31 '24 16:05 ionitron-bot[bot]

https://stackblitz.com/edit/whx41x

To reiterate: when a click event is triggered in any form, all item-sliding should be closed.

q962 avatar Jun 03 '24 13:06 q962

Thanks for the code example! That helped clarify what you're looking for. I confirmed that in native apps, sliding items close when clicking anywhere in the content, not just in the list. I have marked this as a bug to fix since the behavior doesn't match native functionality.

brandyscarney avatar Jun 26 '24 21:06 brandyscarney

Moreover, if you have a list of ion-item-sliding items acting as buttons, such as individual chats in a chat list, and you want to dismiss or close the sliding action and change focus by clicking elsewhere, clicking inadvertently enters the chat you clicked on, even if your intention was just to dismiss the sliding action.

Praise-99 avatar Aug 03 '24 15:08 Praise-99