Popover menu: remove selectionchange listener (#84832)

This commit is contained in:
Matias Chomicki 2024-03-20 16:48:33 +01:00 committed by GitHub
parent 821d9a5565
commit 7e8e7429ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -134,7 +134,6 @@ class UnThemedLogRows extends PureComponent<Props, State> {
});
document.addEventListener('click', this.handleDeselection);
document.addEventListener('contextmenu', this.handleDeselection);
document.addEventListener('selectionchange', this.handleDeselection);
return true;
};
@ -147,17 +146,11 @@ class UnThemedLogRows extends PureComponent<Props, State> {
if (document.getSelection()?.toString()) {
return;
}
// Give time to the browser to process click events originating from the menu before closing it.
// Otherwise selectionchange fires before other click listeners, potentially skipping user actions.
setTimeout(() => {
this.closePopoverMenu();
}, 100);
};
closePopoverMenu = () => {
document.removeEventListener('click', this.handleDeselection);
document.removeEventListener('contextmenu', this.handleDeselection);
document.removeEventListener('selectionchange', this.handleDeselection);
this.setState({
selection: '',
popoverMenuCoordinates: { x: 0, y: 0 },