RFR: 8207333: [linux] Column sorting is triggered always after context menu request on table header

Jose Pereda jpereda at openjdk.org
Tue Apr 1 17:35:34 UTC 2025


Note: The JBS issue [JDK-8207333](https://bugs.openjdk.org/browse/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 for `MouseEvent::isPopupTriggered`, but it doesn't have a check on `mousePressed`. However,  it can be seen that a right click on the header has the following values for `MouseEvent:: isPopupTriggered` on the different platforms and mouse pressed and released events:

| isPopupTriggered on: | Windows  | macOS | Linux |
| ------------- | ------------- | ------------- | ------------- |
| mousePressed  | false  | true | true |
| mouseReleased  | true  | false | false |

Also, the JavaDoc for `MouseEvent:: isPopupTriggered` clearly states that:

> **Note**: Popup menus are triggered differently on different systems. Therefore, `popupTrigger` should be checked in both `onMousePressed` and `mouseReleased` for proper cross-platform functionality.

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.

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

Commit messages:
 - Check popupTrigger on mouse pressed too for tableColumnHeaders

Changes: https://git.openjdk.org/jfx/pull/1754/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1754&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8207333
  Stats: 164 lines in 2 files changed: 162 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jfx/pull/1754.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1754/head:pull/1754

PR: https://git.openjdk.org/jfx/pull/1754


More information about the openjfx-dev mailing list