Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8240640

[macos] Wrong focus behaviour with multiple Alerts

    XMLWordPrintable

    Details

      Backports

        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


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                pbansal Pankaj Bansal (Inactive)
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: