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.

This pull request has now been integrated.

Changeset: 5fdfbce2
Author:    Ziad El Midaoui <[email protected]>
URL:       
https://git.openjdk.org/jfx/commit/5fdfbce2e9676a48f301bb38342ef2819b8d5e9d
Stats:     112 lines in 2 files changed: 109 ins; 0 del; 3 mod

8256142: TreeView: initial focused item incorrect

Reviewed-by: angorya, arapte

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

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

Reply via email to