RFR: 8340344: The first item in TreeView is not aligned in the beginning [v6]

Ambarish Rapte arapte at openjdk.org
Wed May 21 05:11:58 UTC 2025


On Tue, 20 May 2025 15:53:53 GMT, Ziad El Midaoui <zelmidaoui at openjdk.org> wrote:

>> The issue occurred because items preceding an item with children (items with a disclosure node) had different widths, which led to misalignment. This can be fixed by requesting a cell relayout whenever the disclosure node's width changes.
>
> Ziad El Midaoui has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Avoid re-layout items twice after disclosure node width value updated

modules/javafx.controls/src/main/java/javafx/scene/control/skin/TreeCellSkin.java line 232:

> 230:                                 cell.requestLayout();
> 231:                                 cell.layout();
> 232:                             }

Just a minor change please.
The for loop could break when `cell.getIndex() >= indexWithDisclosureNode`, so that we avoid looping through the cells that are after disclosureNode.


for (IndexedCell cell : flow.cells) {
    if (cell != null) {
        if (cell.getIndex() >= indexWithDisclosureNode) {
            break;
        } else if (!cell.isEmpty()) {
            cell.requestLayout();
            cell.layout();
        }
    }
}

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1715#discussion_r2099356105


More information about the openjfx-dev mailing list