On Wed, 11 Mar 2026 13:06:00 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 `TreeTableView`.
>> 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:
>
> Fix TreeTableView initial focus
The test fails on my MacOS 26.2, with below error:
TreeTableViewInitialFocusTest >
testInitialFocusClearedWhenHiddenRootChildrenAreReplaced() FAILED
org.opentest4j.AssertionFailedError: Focused index must be cleared ==>
expected: <-1> but was: <1>
at
app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at
app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at
app//org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
at
app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150)
at
app//org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:563)
at
app//test.robot.javafx.scene.treetableview.TreeTableViewInitialFocusTest.testInitialFocusClearedWhenHiddenRootChildrenAreReplaced(TreeTableViewInitialFocusTest.java:85)
-------------
PR Comment: https://git.openjdk.org/jfx/pull/2104#issuecomment-4039627033