From 15aa23565d9c1c68d0e474714097938a9f7b393e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20St=C3=BCrmer?= Date: Mon, 8 Jan 2018 11:26:19 +0100 Subject: [PATCH] Preserve contextMenuItem onClick event handler argument This change preserves the `onClick` handler's signature of `(event: React.MouseEvent) => void` even if a `panel` is given. Additionally, the event will be removed from the React event pooling system due to the async nature of the `requestAnimationFrame` callback. --- src/components/context_menu/context_menu.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/context_menu/context_menu.js b/src/components/context_menu/context_menu.js index 1ed748591c1..fcf9ee251da 100644 --- a/src/components/context_menu/context_menu.js +++ b/src/components/context_menu/context_menu.js @@ -176,11 +176,14 @@ export class EuiContextMenu extends Component { } = item; const onClickHandler = panel - ? () => { + ? (event) => { + if (onClick && event) { + event.persist(); + } // This component is commonly wrapped in a EuiOutsideClickDetector, which means we'll // need to wait for that logic to complete before re-rendering the DOM via showPanel. window.requestAnimationFrame(() => { - if (onClick) onClick(); + if (onClick) onClick(event); this.showNextPanel(index); }); } : onClick;