Skip to content

Commit 4937238

Browse files
authored
Merge branch 'main' into feature/gfi-set-feature-information
2 parents 0f386c6 + dc27c41 commit 4937238

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

e2e/draw.spec.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,43 @@ test('clicks to the map produce a fetchable pin coordinate', async ({
4040
expect(drawing.features.length).toBe(1)
4141
expect(drawing.features[0].geometry.coordinates[0].length).toBe(7)
4242
})
43+
44+
test('two features drawn at the same coordinate can be modified separately', async ({
45+
page,
46+
}) => {
47+
await openSnowbox(page)
48+
49+
const canvas = await page.locator('canvas')
50+
const boundingBox = await canvas.boundingBox()
51+
if (boundingBox === null) throw new Error('Canvas not found.')
52+
const { width, height } = boundingBox
53+
let { x, y } = boundingBox
54+
55+
x += width / 2
56+
y += height / 2
57+
58+
await page.getByLabel('Draw tools').click()
59+
await page.getByText('Draw and write').click()
60+
await page.getByText('Point').click()
61+
62+
await page.mouse.click(x, y)
63+
await page.mouse.click(x, y)
64+
65+
await page.getByText('Edit').click()
66+
67+
await page.mouse.move(x, y)
68+
await page.mouse.down()
69+
await page.mouse.move(x + 40, y + 40)
70+
await page.mouse.up()
71+
72+
const drawing = JSON.parse(await page.locator(drawTargetId).innerText())
73+
74+
expect(drawing.type).toBe('FeatureCollection')
75+
expect(drawing.features.length).toBe(2)
76+
expect(drawing.features[0].geometry.coordinates[0]).not.toBe(
77+
drawing.features[1].geometry.coordinates[0]
78+
)
79+
expect(drawing.features[0].geometry.coordinates[1]).not.toBe(
80+
drawing.features[1].geometry.coordinates[1]
81+
)
82+
})

packages/plugins/Draw/src/store/createInteractions/createModifyInteractions.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ export default function (
3838
}
3939
}
4040
})
41-
return [
42-
new Modify({ source: drawSource }),
43-
new Snap({ source: drawSource }),
44-
select,
45-
]
41+
42+
const modify = new Modify({ source: drawSource })
43+
modify.on('modifystart', (event) => {
44+
// NOTE: This prevents the user from dragging multiple features. Beware, as dragSegments is an internal property, this might break on an update of OpenLayers
45+
if (event.target.dragSegments_[0]) {
46+
event.target.dragSegments_ = [event.target.dragSegments_[0]]
47+
}
48+
})
49+
50+
return [modify, new Snap({ source: drawSource }), select]
4651
}

0 commit comments

Comments
 (0)