RFR: 8296621: Stage steals focus on scene change [v6]

Kevin Rushforth kcr at openjdk.org
Wed Dec 7 13:11:11 UTC 2022


On Tue, 6 Dec 2022 17:38:45 GMT, Thiago Milczarek Sayao <tsayao at openjdk.org> wrote:

>> Simple fix to not requestFocus() on scene change.
>> 
>> The attached bug sample shows that the TextField focused on the scene remains focused when the scene comes back.
>
> Thiago Milczarek Sayao has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix timeline

Yes, it is a timing problem, most likely related to the performance of my Ubuntu 20.04 VM. I left comments inline with two suggested changes (I think only the first is necessary, but setting iconify before the stage is shown may make the test more robust). With those changes, it fails reliably without your fix and passes reliably with your fix.

tests/system/src/test/java/test/robot/javafx/scene/SceneChangeShouldNotFocusStageTest.java line 54:

> 52:     @Test
> 53:     void windowShouldRemainIconified() {
> 54:         Util.sleep(1000);

I recommend changing this to 2000.

tests/system/src/test/java/test/robot/javafx/scene/SceneChangeShouldNotFocusStageTest.java line 86:

> 84: 
> 85:             stage.show();
> 86:             stage.setIconified(true);

I recommend swapping these two statements.

-------------

PR: https://git.openjdk.org/jfx/pull/940


More information about the openjfx-dev mailing list