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

getSelectedElems() returns an array with an incorrect length #255

Closed
NeilFraser opened this issue Jun 9, 2018 · 1 comment
Closed

getSelectedElems() returns an array with an incorrect length #255

NeilFraser opened this issue Jun 9, 2018 · 1 comment

Comments

@NeilFraser
Copy link
Contributor

Use the selection tool to drag a selection rectangle over some items, then drag the rectangle so that it no longer selects any items, then release the mouse button.

The expected result is that canvas.getSelectedElems() would return an empty array.

But this function actually returns an array that has no contents, but has a length set to the number of objects dragged over. From the console:

Object.getOwnPropertyDescriptors(canvas.getSelectedElems())
length: {value: 4, writable: true, enumerable: false, configurable: false}

This manifests itself as a UI bug in the editor where action buttons are selected when they shouldn't be. Here's a video:
https://www.youtube.com/watch?v=cHw7ErNypno

@NeilFraser
Copy link
Contributor Author

Found the source of the bug:

newSelectedItems.length = len;

https://github.com/SVG-Edit/svgedit/blob/master/editor/svgcanvas.js#L1114

Setting the length explicitly is redundant, and possibly wrong. Deleting this line resolves the problem.

codedread pushed a commit that referenced this issue Jun 11, 2018
* Remove redundant (and incorrect) length set.

Fixes issue #255

* Simplify code by using push instead of a variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant