score:2

I just ran into the same thing. It appears that the onClickAway handler is called before the onClick handlers of its children.

In my case clicking away changes the state so that some of its children won't be rendered. The child with the broken onClick was one of those and was rendered in a react portal so onClickAway was being triggered when clicking on this child. This meant that the child would no longer be rendered by the time it would have triggered its onClick handler.

I don't love this workaround, but wrapping the onClickAway handler in a setTimeout (0ms) fixed the issue for me.

An example:

<ClickAwayListener onClickAway={() => setTimeout(onDelete)}>
...

I'm know this question is a little old and I'm not sure if it fixes your problem but I figured it might help someone that runs into this issue.


Related Query

More Query from same tag