nolimits4web / swiper

Most modern mobile touch slider with hardware accelerated transitions
https://swiperjs.com
MIT License
38.92k stars 9.74k forks source link

Cannot read properties of undefined (reading 'touchId') #7538

Closed luke-rogers closed 3 weeks ago

luke-rogers commented 4 weeks ago

Check that this is really a bug

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:

Validations

Would you like to open a PR for this bug?

nolimits4web commented 4 weeks ago

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

github-actions[bot] commented 4 weeks ago

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.

luke-rogers commented 4 weeks ago

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.