Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
6 tasks done
luke-rogers opened this issue May 16, 2024 · 3 comments
Closed
6 tasks done

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

luke-rogers opened this issue May 16, 2024 · 3 comments

Comments

@luke-rogers
Copy link

luke-rogers commented May 16, 2024

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
@nolimits4web
Copy link
Owner

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

Copy link

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants