Skip to content

Commit

Permalink
Preserve contextMenuItem onClick event handler argument (#265)
Browse files Browse the repository at this point in the history
This change preserves the `onClick` handler's signature of `<T>(event:
React.MouseEvent<T>) => 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.
  • Loading branch information
weltenwort authored Jan 8, 2018
1 parent 9356c61 commit 1b6a952
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/context_menu/context_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1b6a952

Please sign in to comment.