JDK-8240640 : [macos] Wrong focus behaviour with multiple Alerts
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: openjfx14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2020-03-04
  • Updated: 2021-08-05
  • Resolved: 2021-07-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx17Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
MacOS 10.15.3
Java 11, OpenJFX14

A DESCRIPTION OF THE PROBLEM :
This is a regression introduced by:
JDK-8227366 : Wrong stage gets focused after modal stage creation
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8227366

If you have multiple alerts opened on a parent window, pressing the escape multiple times should close each alert in the order they were opened.

This worked correctly before the above linked fix for JDK-8227366 

REGRESSION : Last worked in version 13.0.2

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
* Run the attached test code which opens 3 Alerts on top of a parent Window.
* Press escape 3 times

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All of the Alerts should have closed after pressing the escape key 3 times.
ACTUAL -
After the first press of the escape key once, the focus went to the parent Window meaning the last 2 Alerts remained open.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class FocusBug
{
    public static void main(
        String[] args)
    {
        Application.launch(FocusBugImpl.class);
    }
    
    public static class FocusBugImpl extends Application
    {
        private Stage mStage;
        
        @Override
        public void start(
            Stage stage) throws Exception
        {            
            mStage = stage;
            final BorderPane root = new BorderPane();
            
            stage.setScene(new Scene(root, 500, 500));
            stage.show();
            
            showAlert();
            showAlert();
            showAlert();
        }        
        
        private void showAlert()
        { 
            final Alert alert = new Alert(AlertType.INFORMATION);
            alert.initOwner(mStage);
            alert.show();            
        }
    }
    
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
Changeset: 2cd5d1fd Author: Pankaj Bansal <pbansal@openjdk.org> Date: 2021-07-27 13:22:02 +0000 URL: https://git.openjdk.java.net/jfx/commit/2cd5d1fd0fd3e7d974b46bd43a6f98dbca6f28c0
27-07-2021

Note that JDK-8227366 only manifests on Linux. The fix for that bug, which was done in common code, caused a regression on macOS.
30-06-2021

I have. tried the JDK-8227366 with jdk16b01 and jdk17b03 with latest JavaFX code. I could not see the issue mentioned in JDK-8227366 without the fix done JDK-8227366. I am doing some more investigation into this.
30-06-2021

I can confirm this bug. I can also confirm that if I locally revert the fix for JDK-8227366 then it works as expected.
21-03-2020