Don't dispatch select event if a selected feature is selected again
This commit is contained in:
@@ -281,9 +281,9 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
|
||||
return !this.multi_;
|
||||
}
|
||||
}, this, this.layerFilter_);
|
||||
if (selected.length > 0 && features.getLength() == 1 &&
|
||||
features.item(0) == selected[0]) {
|
||||
if (selected.length > 0 && features.getLength() == 1 && features.item(0) == selected[0]) {
|
||||
// No change; an already selected feature is selected again
|
||||
selected.length = 0;
|
||||
} else {
|
||||
if (features.getLength() !== 0) {
|
||||
deselected = Array.prototype.concat(features.getArray());
|
||||
|
||||
@@ -144,6 +144,20 @@ describe('ol.interaction.Select', function() {
|
||||
expect(features.getLength()).to.equal(0);
|
||||
});
|
||||
|
||||
it('select twice with single-click', function() {
|
||||
var listenerSpy = sinon.spy(function(e) {
|
||||
expect(e.selected).to.have.length(1);
|
||||
});
|
||||
select.on('select', listenerSpy);
|
||||
|
||||
simulateEvent(ol.MapBrowserEvent.EventType.SINGLECLICK, 10, -20);
|
||||
simulateEvent(ol.MapBrowserEvent.EventType.SINGLECLICK, 9, -21);
|
||||
|
||||
expect(listenerSpy.callCount).to.be(1);
|
||||
|
||||
var features = select.getFeatures();
|
||||
expect(features.getLength()).to.equal(1);
|
||||
});
|
||||
|
||||
it('select with shift single-click', function() {
|
||||
var listenerSpy = sinon.spy(function(e) {
|
||||
|
||||
Reference in New Issue
Block a user