Skip to content

Commit

Permalink
[51836] Widget options popup scrolls up with the page (#15016)
Browse files Browse the repository at this point in the history
* close context menu if it is scrolled out side of it

* first check if wrapper exists then add event listener to it

* fix eslint error
  • Loading branch information
bsatarnejad committed Mar 18, 2024
1 parent 89eeb82 commit 959ed27
Showing 1 changed file with 15 additions and 6 deletions.
Expand Up @@ -61,13 +61,22 @@ export class OPContextMenuService {
return true;
});

// Listen to any click and close the active context menu
const that = this;
document.getElementById('wrapper')!.addEventListener('click', (evt:Event) => {
if (that.active && !that.portalHostElement.contains(evt.target as Element)) {
that.close();
}
}, true);
const wrapper = document.getElementById('wrapper');
if (wrapper) {
// Listen to any click and close the active context menu
wrapper.addEventListener('click', (evt:Event) => {
if (that.active && !that.portalHostElement.contains(evt.target as Element)) {
that.close();
}
}, true);
// Listen if it scrolles then close the active context menu
wrapper.addEventListener('scroll', (evt:Event) => {
if (that.active && !that.portalHostElement.contains(evt.target as Element)) {
that.close();
}
}, true);
}
}

/**
Expand Down

0 comments on commit 959ed27

Please sign in to comment.