-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Select style multiple select interactions removed #10490
Select style multiple select interactions removed #10490
Conversation
Thanks for your contribution! I think a new test would be in order, although your code seems like it should fix the problem. Please let me know if you need indications. |
I had a look at the existing tests. I'll probably find a way how to test this. But I'm in doubt what the best place is. a top-level |
I'd say a top level
Thanks |
All right. I had some trouble finding the right way to test this. I couldn't get my test to fail when I reverted my fix :-( |
@jahow Could you have a look at the test result? There is one failing test for |
I now have exactly the same test code as where I started but the build succeeds now. |
Unrelated failed tests seem to be quite common, for example see #7437 (comment) Any change even an edit to a comment will rerun the tests as will squashing and force pushing which also tidies the commit history. |
@jahow Indeed. The tests are passing now, even if the code is the same. I made a few commits that cancel each other. |
if (map) { | ||
this.features_.addEventListener(CollectionEventType.ADD, this.boundAddFeature_); | ||
this.features_.addEventListener(CollectionEventType.REMOVE, this.boundRemoveFeature_); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (map) {
if (!currentMap) {
// ...
}
// ...
is needed.
For such a code:
import Map from 'ol/Map';
import Select from 'ol/interaction/Select';
var map1 = new Map(/* ... */);
var map2 = new Map(/* ... */);
var selectInteraction = new Select();
// Attach interaction to a map1.
selectInteraction.setMap(map1);
// Change map for interaction to map2.
selectInteraction.setMap(map2);
there will be two listeners per event.
This fixes issue 10486 by removing the event listeners when an interaction is removed from a map.
event handlers have to be (de)activated when the interaction is added or removed to the map, not when constructed added unit test
drop superfluous if.
7d11faf
to
ad77143
Compare
Rebased; fixed merge conflicts. |
This fixes #10486 by removing the event listeners when an
interaction is removed from a map.