JDK-8118995 : Regression: MenuButton popup is sometimes positioned far below its button
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8
  • Priority: P2
  • Status: Resolved
  • Resolution: Cannot Reproduce
  • Submitted: 2013-10-04
  • Updated: 2015-06-17
  • Resolved: 2013-11-04
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.
JDK 8
8Resolved
Related Reports
Relates :  
Description
Load the attached fxml (using FXMLLoader.load() or SB 2.0).
- Open the Properties TitledPane, and move the scrollbar until getting the "MenuButton Issue..." row.
- Click on the arrow MenuButton: OK
- Click in the textfield on its left, and enter "a"
- Click again on the arrow MenuButton: the popup appears very far below the MenuButton: bug

You can note that surprisingly as soon as the text field is empty, the MenuButton popup is displayed correctly.


Comments
I agree with Martin - I can no longer reproduce this issue using the attached test cases.
04-11-2013

I'm not able to reproduce this issue (on Linux) using both original sample and the one from Jonathan. Jonathan, can you confirm that is no longer reproducible?
04-11-2013

Assign to Jonathan to dispatch.
30-10-2013

hg bisect says - The first bad revision is: changeset: 4918:3f656fbd508f user: mickf date: Mon Sep 02 13:44:19 2013 +0100 summary: RT-31901 - Regression: scrollbar issue with TitledPane
13-10-2013

I have investigated this issue. Here's a summary of my findings: Firstly I thought the issue was in com.sun.javafx.Utils.getBounds(Object) as I was seeing weird bounds being calculated on the line 'n.localToScene(n.getLayoutBounds());'. This suggested to me that the ScrollPane was doing something weird, and I was worried I would have to include special case support for ScrollPane when calculating bounds. However, knowing that the TextField caret has been causing some troubles recently, I tried something else: after scrolling the scrollpane and entering the text, I clicked elsewhere so that the TextField no longer had focus. After doing this the menu would consistently appear at the expected location. This therefore suggests that the TextField caret had something to do with this. Investigating further I was able to fix this issue in TextFieldSkin by replacing the following line: textGroup.getChildren().addAll(selectionHighlightPath, textNode, new Group(caretPath)); with this: textGroup.getChildren().addAll(selectionHighlightPath, textNode, caretPath); To make recreating this bug easier, I have created (and attached) a simpler test case to this issue. To reproduce is simple: 1) Click on the MenuButton - note the correct menu placement 2) Enter a character into the TextField and click on the MenuButton - again, correct menu placement 3) Scroll the ScrollPane 4) Click on the MenuButton - again, correct menu placement 5) Enter a character into the TextField and click on the MenuButton again - note now that the menu is incorrectly offset on the y-axis. What is interesting is the need to enter the character. If you do not do this, the menu always places correctly, regardless of whether the TextField had focus or not. Perhaps the TextField bounds are being recalculated on focus loss, due to a pulse being forced, which otherwise does not happen in time for the MenuButton press (resulting in the menu appearing in the incorrect position). I'm reassigning this issue to Leif, given the nature of the issue has changed to being TextField related. However, Leif, if you do not have the bandwidth let me know and I will reassign this issue again.
10-10-2013

Thanks, I am now able to run the testcase fine. Also thanks for the tip on using SB to generate a controller.
08-10-2013

Thanks Paru to had a quick look on this one. FYI, you can generate a controller (using SB 1.1 for now) with menu" View>Show sample controller skeleton". For your convenience, I have attached a NB project, you only have to unzip, open, set your jdk8 in the properties, and run.
08-10-2013

Could you please also attach the controller class? I am able to run it using SB 2.0 but unable to do it with a simple Application that does FXMLLoader.load(getClass().getResource("MenuButtonIssue.fxml"). It complains that the controller class is missing. It would be easier to run it outside of SB 2.0 to debug the issue. thanks.
07-10-2013

Seems potentially related to RT-27546, which Paru is currently investigating.
04-10-2013

Note that the test case works fine with FX 2.2
04-10-2013