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

Fixing onSelect being called when objects were not intersected #5632

Merged
merged 5 commits into from
Apr 17, 2019

Conversation

rpFilipe
Copy link
Contributor

@rpFilipe rpFilipe commented Apr 10, 2019

PR fixing the bug stated on the issue #5596

The onSelect method is only called after we determine that the multiselect intersects the object. If the onSelect returns 'false' we discard them from the group.

close #5596

// only add one object if it's a click
if (isClick) {
break;
}
}
}

if (group.length > 1) {
group = group.filter(function(object) {
return !object.onSelect({ e: e });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about wrapping group.push(currentObject) in the if with this condition?

if (!object.onSelect({ e: e })) {
  group.push(currentObject);
}

so we avoid the other if and the filter operation, just because is 5 lines extra not because i do not like it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my initial implementation. However, if the selection only intersected one object the onSelect() method would be called 2 times. one in this method and another on __setActiveObject(). That requires changing the _setActiveObject() to have a flag to not call the onSelect() if we are 'coming' from the __onCollectObjects(). I was reluctant to change as it could impact many operations. However, if you like that aproach better let me know and I'll do a refactoring

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, at this point this solution is better.

We still need tests. Can you write them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i wasn't able this weekend, but I'll work on it this week. I'll keep you updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asturur Already implemented the tests. If you need anything more just let me know

@asturur
Copy link
Member

asturur commented Apr 11, 2019

Do not forget we need to add a unit test for this change.

If you can't run them locally or you do not know how to do, please ask. I can help

@rpFilipe
Copy link
Contributor Author

I'll see the implemented tests and try to create a test for this change. I'll probaly need yout help :) I'll let you know.

@asturur
Copy link
Member

asturur commented Apr 17, 2019

i think is ok!
I ll test it better as soon as i can, but i think we can merge it.
The code changes looks fine and the test cover enough of it.

@asturur asturur merged commit 96131c7 into fabricjs:master Apr 17, 2019
@rpFilipe
Copy link
Contributor Author

Ok. Do you have any estimates of when this will be released?

@rpFilipe rpFilipe deleted the onSelect_Fix branch April 17, 2019 14:31
@asturur
Copy link
Member

asturur commented Apr 27, 2019

This will be in the bundle of fabricJS 3.0
I wanted to solve the clipPath blurryness with that release, but since is taking too long i think i ll move on with a release anyway.

@asturur asturur mentioned this pull request May 19, 2019
thiagocunha pushed a commit to thiagocunha/fabric.js that referenced this pull request Nov 18, 2019
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

Successfully merging this pull request may close these issues.

onSelect called when the object is not selected.
2 participants