From bba1b124483dd557bdc3fa5efe47bc512803552c Mon Sep 17 00:00:00 2001 From: Matias Chomicki Date: Fri, 15 Mar 2024 16:24:41 +0100 Subject: [PATCH] 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 --- public/app/features/logs/components/LogRows.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/app/features/logs/components/LogRows.tsx b/public/app/features/logs/components/LogRows.tsx index e675ff33967..03110895b35 100644 --- a/public/app/features/logs/components/LogRows.tsx +++ b/public/app/features/logs/components/LogRows.tsx @@ -147,7 +147,11 @@ class UnThemedLogRows extends PureComponent { 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 { componentWillUnmount() { document.removeEventListener('click', this.handleDeselection); document.removeEventListener('contextmenu', this.handleDeselection); + document.removeEventListener('selectionchange', this.handleDeselection); if (this.renderAllTimer) { clearTimeout(this.renderAllTimer); }