panes icon indicating copy to clipboard operation
panes copied to clipboard

[BUG] this.step[...].posY would benefit from null checking

Open rgoldiez opened this issue 4 years ago • 5 comments

I can't pinpoint the exact scenario, but this.steps can be an empty array. Most places in events.ts have null checking with typescript's ? optional chaining operator except this one:

https://github.com/roman-rr/cupertino-pane/blob/5b49dc37dbc33a67093d473053872975dc816ba6/src/events.ts#L252

We've seen a few Cannot read properties of undefined (reading 'posY') errors come through our logging framework. In reading through the code, it seems that the line above can be the only culprit. It would be good add optional chaining here, too.

rgoldiez avatar Feb 21 '22 23:02 rgoldiez

@rgoldiez Thank you for report. Always using an optional chaining is a compromise. And here is a good litmus paper to know the exact reason of issue and fix it in correct way. So, decided to fix rather than use additional compromise with chaining.

Bug is easy to reproduce: just hold touchmove action on pane initialization and touchstart will be skipped.

Should be fixed in last commit!

roman-rr avatar Mar 12 '22 18:03 roman-rr

@roman-rr - great find and fix! Thank you!

rgoldiez avatar Mar 12 '22 19:03 rgoldiez

I'm new to this, but how do I download the latest version with this bug fixed?

EdithOrt avatar Mar 15 '22 02:03 EdithOrt

Hello @EdithOrt You could install package right from git repository.

npm install git+https://github.com/roman-rr/cupertino-pane.git

roman-rr avatar Mar 15 '22 06:03 roman-rr

Thanks @roman-rr , it helped me.

EdithOrt avatar Mar 16 '22 19:03 EdithOrt