We are hitting this quite frequently, since focus runs on the main thread, it is possible for the focus change to occur between the call to inEdtFocusOwner and the call to FocusMonitor.attachTo(target) in the code below:
The result is that focusMonitor never gets a focusGained event since the focus transition has already occurred, and therefore hasFocus returns false even though focus has indeed changed to the target. The timeout loop further down ends up throwing an ActionFailedException "Focus change to X failed"
The fix would be to call inEdtFocusOwner() again after the attachTo call, and if it returns the target, remove the focus listener and return.
We are hitting this quite frequently, since focus runs on the main thread, it is possible for the focus change to occur between the call to inEdtFocusOwner and the call to FocusMonitor.attachTo(target) in the code below:
The result is that focusMonitor never gets a focusGained event since the focus transition has already occurred, and therefore hasFocus returns false even though focus has indeed changed to the target. The timeout loop further down ends up throwing an ActionFailedException "Focus change to X failed"
The fix would be to call inEdtFocusOwner() again after the attachTo call, and if it returns the target, remove the focus listener and return.