nolimits4web / swiper

Most modern mobile touch slider with hardware accelerated transitions

Home Page:https://swiperjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read properties of undefined (reading 'touchId')

luke-rogers opened this issue · comments

Check that this is really a bug

  • I confirm

Reproduction link

Unsure on reproduction steps

Bug description

Cannot read properties of undefined (reading 'touchId') - occurring from here when data is undefined.

Happy to raise a PR to protect against data being undefined however I'm unsure if that's just covering up another issue.

let e = event;
if (e.originalEvent) e = e.originalEvent;
let targetTouch;
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
if (!isTouchEvent) {
    if (data.touchId !== null) return; // return from pointer if we use touch 
    // ^^ error here when data is undefined
    if (e.pointerId !== data.pointerId) return;
    targetTouch = e;
} else {
    targetTouch = [...e.changedTouches].filter(t => t.identifier === data.touchId)[0];
    if (!targetTouch || targetTouch.identifier !== data.touchId) return;

Expected Behavior

No error occurs when data is undefined

Actual Behavior

Cannot read properties of undefined (reading 'touchId')

Swiper version

11.1.3

Platform/Target and Browser Versions

We can see reports in Sentry for the following Chrome versions:

  • Chrome 101.0.4951
  • Chrome 102.0.5005
  • Chrome 86.0.4240
  • Chrome 104.0.0
  • Chrome 103.0.5060
  • Chrome 100.0.4896

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR

Repro steps are required as i can't imagine a situation when that touchEventsData is undefined

Hello @luke-rogers. Please provide a online reproduction by codesandbox or a minimal GitHub repository. You can fork one of our demos in codesandbox to get start. Issues labeled by missing demo will be closed if no activities in 3 days.

I don't have reproduction steps right now, just a handful of reports in Sentry.

We are looking at implementing session replay soon so I will have to come back when I have a reproduction.