On Fri, 20 Mar 2026 15:04:42 GMT, Ziad El Midaoui <[email protected]> 
wrote:

>> The bug occurs when `showRoot` is set to false on a root with no children, 
>> the expanded item count drops is 0 causing `isFocused(0)` to return false 
>> even though `focusedIndex` is still 0. When items are added afterwards the 
>> `treeItemListener` sees `focusedIndex=0` and incorrectly shifts it to 1 
>> placing the focus on second item of the TreeView.
>> The fix replaces `isFocused(0)` with `getFocusedIndex() >= 0`, which reads 
>> the raw stored index.
>
> Ziad El Midaoui has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Minor test changes

And pretty sure that is also why it is not reproducable with headless tests. 
The `StubToolkit` does not run anything later.

https://github.com/openjdk/jfx/blob/9c0228bb863280471644a8eed59c1db971f027dd/modules/javafx.graphics/src/test/java/test/com/sun/javafx/pgstub/StubToolkit.java#L186-L189

So it makes testing also worse.
@andy-goryachev-oracle What do you think at removing the `Platform.runLater()` 
calls in `Control`s at one point? I could find 13 matches, where some are fine, 
but some (like here) are not and seems like a weird decision.

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

PR Comment: https://git.openjdk.org/jfx/pull/2095#issuecomment-4099204993

Reply via email to