Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8260977

TreeView cell selection is 1px off after expansion is triggered at least once

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      All OS, JavaFX 16 as provided by Gluon or built from github master

      A DESCRIPTION OF THE PROBLEM :
      Clicking on a pixel right at the top of a TreeCell selects the cell above it, provided the tree changed at least once (node expansion).

      End-users will typically not notice because they rarely click just between two tree cells, and in case the wrong cell gets selected they will think they missed and click again. But an automated tool or code-based events will fail.

      I have narrowed this down to a single commit and single line change:

      Github commit: d10f948ee7380ac73bc4e2d5bff1caba50fe00a8

      Java Bug ID: 8252811

      Removing the call to sheetChildren.clear() in VirtualFlow.java is what ultimately is causing this, though I don't know why or how exactly.

      The tiny deviation in TreeCell selection shows that the side-effects of github commit d10f948ee7380ac73bc4e2d5bff1caba50fe00a8 are not fully understood, which should outweigh the possible performance gain of that commit. I suggest that the commit should get reverted before the JavaFX 16 release and then re-evaluated.

      REGRESSION : Last worked in version 15.0.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run this on screen with scaling 100%.

      Open a TreeView, e.g. the one in the ensemble demo.

      Before expanding any node, select a node.

      Activate the magnifier window and turn it up high, to about 500%.

      Aim the mouse exactly at the top of the celected cell and click to get a feel for it. Clicking a topmost pixel should keep the selection on the cell.

      Expand a tree-node.

      Click again on a topmost pixel of the selected cell.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Cell selection should not change.
      ACTUAL -
      The cell above the one that was clicked gets selected.

      ---------- BEGIN SOURCE ----------
      Github commit: d10f948ee7380ac73bc4e2d5bff1caba50fe00a8 and ensemble demo
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Undo the change for sheetChildren.clear() in VirtualFlow.java

      diff --git a/modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java b/modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
      index b7e3400d7b..dd68d795d3 100644
      --- a/modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
      +++ b/modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
      @@ -835,7 +835,7 @@ public class VirtualFlow<T extends IndexedCell> extends Region {
                   // lead to performance degradation until it is handled properly.
                   if (countChanged) {
                       layoutChildren();
      -
      + sheetChildren.clear();
                       Parent parent = getParent();
                       if (parent != null) parent.requestLayout();
                   }


      FREQUENCY : always


        1. cell_above.png
          cell_above.png
          713 kB
        2. cell.png
          cell.png
          741 kB

            jpereda Jose Pereda
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: