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 modules/javafx.controls/src/main/java/javafx/scene/control/TreeTableView.java line 3667: > 3665: // shift if the tree item is expanded > 3666: TreeItem<S> eventTreeItem = e.getTreeItem(); > 3667: if (!treeTableView.isShowRoot() When comparing this with https://github.com/openjdk/jfx/pull/2095, shouldn't we instead also have the logic in the showRoot listener? Or is the logic different? tests/system/src/test/java/test/robot/javafx/scene/treetableview/TreeTableViewInitialFocusTest.java line 50: > 48: import static org.junit.jupiter.api.Assertions.assertNull; > 49: > 50: public class TreeTableViewInitialFocusTest { I think a simple Unit test would fit this case better doesn't it? This should be easy to setup as a normal JUnit headless test as far as I can see. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/2104#discussion_r2925235171 PR Review Comment: https://git.openjdk.org/jfx/pull/2104#discussion_r2925219533
