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
51.13k stars 13.5k forks source link

bug: Swipe to dismiss not working properly on toast with customized ::part(container) css #29998

Closed aeharding closed 1 week ago

aeharding commented 3 weeks ago

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

I have some CSS to center the toast message with its icon. Here is the css:

ion-toast::part(container) {
  display: inline-flex;
  transform: translateX(-50%);
  left: 50%;
  position: relative;
}

With this CSS, I can no longer swipe to dismiss unless I start the swipe from over the .toast-container element:

image

This is because the ion-toast has pointer-events: none and it is reset on the .toast-container element with pointer-events: auto.

Expected Behavior

Can swipe from anywhere on the toast, even with custom layout applied to ::part(container)

Steps to Reproduce

  1. Visit https://stackblitz.com/edit/kvqhk5
  2. Open toast
  3. Try to swipe from the far left and right sides of the toast. Observe it doesn't work.
  4. Try to swipe from the center of the toast. Observe it works.

Code Reproduction URL

https://stackblitz.com/edit/kvqhk5

Ionic Info

Latest Ionic Stackblitz

Additional Information

This could be fixed by moving pointer-events: auto from .toast-container to .toast-wrapper. I will make a pr :)