-
Notifications
You must be signed in to change notification settings - Fork 506
8207333: [Linux, macOS] Column sorting is triggered always after context menu request on table header #1754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back jpereda! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
I'll take a look. |
I can only test it on macOS and Windows. Could someone with a linux system help please? |
@andy-goryachev-oracle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for fixing this bug, @jperedadnr !
testing with the monkey tester looks good on macOS 15.3.2 and windows 11.
@Ziad-Mid could you be the second reviewer? |
I can't test on Linux , I will check same for macOS |
@@ -243,6 +245,7 @@ public TableColumnHeader(final TableColumnBase tc) { | |||
} | |||
|
|||
if (me.isConsumed()) return; | |||
popupTriggeredOnMousePressed = me.isPopupTrigger(); | |||
me.consume(); | |||
|
|||
header.getTableHeaderRow().columnDragLock = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Mac a context menu can be invoked using the right button or the left button in conjunction with the Control key. In the second case the pop trigger flag will be set and the primary button will be down. If I'm reading the code correctly this could get the header stuck in column re-ordering mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing on macOS 15.3.2, it does not get stuck when using control+left-click, works as expected.
There is one (existing and unrelated) problem - if the user tries to dismiss the popup menu by clicking on the header, it dismisses the popup (correctly), but then proceeds to re-sort the table (unexpected).
One can say it works as designed, since the click falls on a header cell and the expected operation is to toggle the sorting, with the side effect of dismissing the popup.
On the other hand, Excel (both mac and windows) behaves differently - a click on the spreadsheet header dismisses the popup and does not select the column, as it normally does when no popup is present.
What do you guys think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
control+left-click works as expected for me too.
When the context menu is showing, clicking anywhere outside of it, closes the popup (because of the autohide property), but doesn't consume the event. If you click on a button, for instance, it will be fired. In any case, this is the same before and after this PR, so maybe an issue for a later discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely an unrelated issue, I just wanted to ask whether you guys think it crosses the threshold for a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
control+left-click works as expected for me too.
For control+left-click it looks like the code will call columnReordingStarted
but on the released event it won't call columnReorderingComplete
. I have no idea if this will lead to problems or not.
@@ -271,7 +274,10 @@ public TableColumnHeader(final TableColumnBase tc) { | |||
TableColumnHeader header = (TableColumnHeader) me.getSource(); | |||
header.getTableHeaderRow().columnDragLock = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Ubuntu 22.04 the table column header is not receiving a mouse released event if a context menu is shown. Not sure where the released event is going but it's not to any node on the primary stage. The docs are vague on this but this looks like a separate bug that's making it hard to test this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens in the master branch (without this PR's changes)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was having trouble reproducing the original bug on the master branch; the sorting is done when the mouse is released and most of the time that event never arrives (I think it does every now and then).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is strange - the bug is immediately apparent. which macOS version do you have? although I don't think the version matters.
I am testing with an external mouse, with control-left-click, and with the double-finger-click gesture on the trackpad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was having problems reproducing on Linux. No problem reproducing on macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Linux I have some issues too: the test that I attached to the JBS issue doesn't fail for me on Linux, but the test that I added to this PR does fail without the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try the monkey tester? it allows setting properties on the table view / table column at runtime...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just verified that on Linux the released event usually goes to the popup window. Basically it's whatever window is under the cursor at the time; if I move the mouse fast enough it may go to a node on the primary stage. I don't think this is our doing, it's how GTK is delivering the event.
On the JavaFX side I'm not sure this counts as a bug. The docs state that entered and released events should arrive in pairs during drag and drop operations but doesn't address this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Monkey tester app works for me on Linux (Ubuntu 22.04, either mouse or pad), before and after this PR (so I can't reproduce the issue there, as I mentioned, though the test added to the PR fails without the patch).
Note: The JBS issue JDK-8207333 refers to Linux, but it happens on macOS too.
When a TableColumn has a ContextMenu, if the user right clicks on the tableColumnHeader, the ContextMenu shows up, but, as described on the issue, on macOS and Linux, the table gets sorted as well.
Currently,
TableColumnHeader#mouseReleasedHandler
checks forMouseEvent::isPopupTriggered
, but it doesn't have a check onmousePressed
. However, it can be seen that a right click on the header has the following values forMouseEvent:: isPopupTriggered
on the different platforms and mouse pressed and released events:Also, the JavaDoc for
MouseEvent::isPopupTriggered
clearly states that:Therefore, this PR adds a check to
MouseEvent::isPopupTrigger
in the mouse pressed event, that can be used later on to cancel the header sorting when the mouse released event happens.Also a system test has been added. It fails on macOS and Linux, and passes on Windows before this PR, and passes on the three platforms with this PR.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1754/head:pull/1754
$ git checkout pull/1754
Update a local copy of the PR:
$ git checkout pull/1754
$ git pull https://git.openjdk.org/jfx.git pull/1754/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1754
View PR using the GUI difftool:
$ git pr show -t 1754
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1754.diff
Using Webrev
Link to Webrev Comment