CallOutBox is not toggled

I show a CallOutBox asynchronously when a button is clicked. If the button is clicked again the CallOutBox should close. The behaviour I am seeing is a bit different though: The CallOutBox is closed on button down. On button up the button click is triggered again and the CallOutBox will be shown again.

There is a comment in inputAttemptWhenModal that hints that the expected behavior is that the CallOutBox should not be shown again but it seems the button click goes through even though it shouldn’t:

if (targetArea.contains (mousePos)) { // if you click on the area that originally popped-up the callout, you expect it // to get rid of the box, but deleting the box here allows the click to pass through and // probably re-trigger it, so we need to dismiss the box asynchronously to consume the click.. postCommandMessage (callOutBoxDismissCommandId); }

Is there a fix or workaround to enable the toggle behaviour?

I've encountered the same problem with enabling toggle behaviour for a CallOutBox, has anyone found a workaround for this?