JDK-8260977 : TreeView cell selection is 1px off after expansion is triggered at least once
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: openjfx16
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2021-02-02
  • Updated: 2022-01-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
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



Comments
I can't make it fail on Mac.
03-02-2021

The bug only manifests after you expand a node in the TreeView, for example, Item 3. It works correctly when the app is initially displayed. Only after expanding Item 3 can you see the bug, and only when you hover (or click) exactly on the boundary between Item 2 and Item 3. This is on Windows 10, so I will try it on Mac and see if I can reproduce it there.
03-02-2021

I've run some tests on Mac, with JavaFX 14.0.2, 15, 15.0.1 and 16-ea+6. For that, I've added some visual help: .tree-cell { -fx-border-color: red transparent green transparent; } .tree-cell:hover { -fx-background-color: yellowgreen; } and set Mac zoom to the maximum. See attached files: - cell.png with mouse hotspot at 460x355, which is the red top border of the cell 2. - cell_above.png, with mouse hotspot at 460x354, which is the green bottom border of the cell 1 I don't see differences between the JavaFX versions. What am I missing?
03-02-2021

I can reproduce the bug on JavaFX 16, and also confirm that locally reverting the fix for JDK-8252811 resolves the issue. [~jpereda] Do you have any ideas on this?
02-02-2021

Based on the information provided, this is a regression caused by the fix for JDK-8252811.
02-02-2021