On Thu, 5 Mar 2026 15:51:51 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. The behavior seems to be correct with the reproducer, and no ill effects in the monkey tester. I think we should add a test and it's ready to go, 1 reviewer should be sufficient. I noticed that the `TreeTableView` seems to exhibit the same issue, you can use this reproducer to verify: https://github.com/andy-goryachev-oracle/Test/blob/main/src/goryachev/bugs/TreeView_Focus_8256142.java We could either change the JBS ticket to include the `TreeTableView`, or create a new ticket and a new PR. What do you think? ------------- PR Comment: https://git.openjdk.org/jfx/pull/2095#issuecomment-4013725029
