setupDragAndDrop fails when used in a UWP JS application
Bug Template
Describe the bug When using PXT (as part of the PXT-Sample code) inside a UWP app the editor crashes with an unhandled exception in the function toArray in pxtapp.js. The root cause of this issue is that e.clipboardData.files is null when pasting into a UWP but not when pasting into the browser. So the call to toArray contains a null item and throws:
Unhandled exception at line 732, column 33 in ms-appx-web://microsoft.datastreamerconnect/pxtapp.js 0x800a138f - JavaScript runtime error: Unable to get property 'length' of undefined or null reference occurred
Adding a check for e.clipboardData.files != null around the "has file?" check enables the if to go to items.
To Reproduce This isn't straight forward as you have to create a UWP blank UWP JS app then use "pxt staticpkg" to create a static version of the site. You can then place those files into the blank UWP App, fix up the entry point etc and run the app. When you do you'll be able to reproduce the issue:
- Run UWP app
- Create new project
- Switch to JavaScript
- Paste in code
Expected behavior The expected behavior is that the pasted code appears.
Desktop (please complete the following information):
- OS: Windows 10
- Browser: Microsoft Edge
- Version: Microsoft Edge 42.17134.1.0 Microsoft EdgeHTML 17.17134
Closing old bugs. If this still reproduces please reopen.