Logs popover: allow click listeners to run before closing the menu (#84583)

* Logs popover: allow click listeners to run before closing the menu

* Decrease buffer time
This commit is contained in:
Matias Chomicki
2024-03-15 17:24:41 +02:00
committed by GitHub
parent 200ff7f9b4
commit bba1b12448
@@ -147,7 +147,11 @@ class UnThemedLogRows extends PureComponent<Props, State> {
if (document.getSelection()?.toString()) {
return;
}
this.closePopoverMenu();
// 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 = () => {
@@ -177,6 +181,7 @@ class UnThemedLogRows extends PureComponent<Props, State> {
componentWillUnmount() {
document.removeEventListener('click', this.handleDeselection);
document.removeEventListener('contextmenu', this.handleDeselection);
document.removeEventListener('selectionchange', this.handleDeselection);
if (this.renderAllTimer) {
clearTimeout(this.renderAllTimer);
}