bug: ion-item-sliding should close automatically when clicking anywhere in the content
Prerequisites
- [X] I have read the Contributing Guidelines.
- [X] I agree to follow the Code of Conduct.
- [X] I have searched for existing issues that already include this feature request, without success.
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.
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!
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.
https://stackblitz.com/edit/whx41x
To reiterate: when a click event is triggered in any form, all item-sliding should be closed.
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.
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.