Skip to content

Commit 4953db7

Browse files
committed
Fix disable dragPan after second click on feature
Closes #1328
1 parent 42818a8 commit 4953db7

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/modes/direct_select.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ DirectSelect.fireActionable = function(state) {
2828
};
2929

3030
DirectSelect.startDragging = function(state, e) {
31-
state.initialDragPanState = this.map.dragPan.isEnabled();
31+
if (state.initialDragPanState == null) {
32+
state.initialDragPanState = this.map.dragPan.isEnabled();
33+
}
3234

3335
this.map.dragPan.disable();
3436
state.canDragMove = true;
@@ -39,6 +41,8 @@ DirectSelect.stopDragging = function(state) {
3941
if (state.canDragMove && state.initialDragPanState === true) {
4042
this.map.dragPan.enable();
4143
}
44+
45+
state.initialDragPanState = null;
4246
state.dragMoving = false;
4347
state.canDragMove = false;
4448
state.dragMoveLocation = null;

test/direct_select.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,33 @@ test('direct_select', async (t) => {
5353
}
5454
});
5555

56+
await t.test('direct_select - double click should not disable enabled dragPan', async () => {
57+
const ids = Draw.add(getGeoJSON('polygon'));
58+
59+
Draw.changeMode(Constants.modes.DIRECT_SELECT, {
60+
featureId: ids[0]
61+
});
62+
63+
await afterNextRender();
64+
65+
spy(map.dragPan, 'enable');
66+
spy(map.dragPan, 'disable');
67+
68+
69+
for (let i = 0; i < 2; i++) {
70+
map.fire('mousedown', makeMouseEvent(35, 25));
71+
await afterNextRender();
72+
}
73+
74+
map.fire('mousemove', makeMouseEvent(0, 0));
75+
76+
assert.equal(map.dragPan.enable.callCount, 1, 'dragPan.enable called');
77+
78+
map.dragPan.enable.restore();
79+
map.dragPan.disable.restore();
80+
});
81+
82+
5683
await t.test('direct_select - should fire correct actionable when no vertices selected', async () => {
5784
const ids = Draw.add(getGeoJSON('polygon'));
5885
Draw.changeMode(Constants.modes.SIMPLE_SELECT, {

0 commit comments

Comments
 (0)