mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 03:42:37 +02:00
chore: always insert contextmenu on map container parent
offsetParent will return whatever positionned parent element, so when clicking on a marker it will be the marker container. And we cannot add the contextmenu inside the map container, as it the focusout element will be sent before the click action happen on any item of the contextmenu.
This commit is contained in:
parent
3c0d2b79ef
commit
581ec242b8
1 changed files with 5 additions and 2 deletions
|
@ -15,7 +15,6 @@ export default class ContextMenu extends Positioned {
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
open(event, items) {
|
||||
const left = event.clientX
|
||||
const top = event.clientY
|
||||
|
@ -43,7 +42,11 @@ export default class ContextMenu extends Positioned {
|
|||
this.container.appendChild(li)
|
||||
}
|
||||
}
|
||||
const parent = document.elementFromPoint(left, top).offsetParent
|
||||
// When adding contextmenu below the map container, clicking on any link will send the
|
||||
// "focusout" element on link click, preventing to trigger the click action
|
||||
const parent = document
|
||||
.elementFromPoint(left, top)
|
||||
.closest('.leaflet-container').parentNode
|
||||
parent.appendChild(this.container)
|
||||
if (this.options.fixed) {
|
||||
this.setPosition({ left, top })
|
||||
|
|
Loading…
Reference in a new issue