RFR: 8237453: [TabPane] Incorrect arrow key traversal through tabs after reordering

Ambarish Rapte arapte at openjdk.java.net
Wed Feb 5 11:13:49 UTC 2020

Dragging a tab and dropping it back to it's original position causes an incorrect reordering of tabs. Incorrect order of tabs can be observed using arrow key traversal through tabs.

Below mechanism of identifying if tab header is dragged and dropped at same position is not reliable. 
When a tab is selected for dragging, the tab's layout X is stored as `dragHeaderStartX`.
When the tab is dropped, the tab's destination layout X is saved as `dragHeaderDestX`.
These two values are used to decide if the reordering of tabs is needed.
This is an unreliable mechanism in two cases,

1. When the `TabPane.TabClosingPolicy` is set to `TabPane.TabClosingPolicy.SELECTED_TAB`, the close button icon gets added only to the selected tab. 
Each time when the tab selection is changed, the header region needs a re-layout. When a non selected tab is chosen for dragging `dragHeaderStartX` and `dragHeaderDestX` will always differ.

2. Calculation of `dragHeaderDestX` involves floating point operation. So the computed `dragHeaderDestX` may sometimes vary by fraction than `dragHeaderStartX`.

Use the index of tab header for identifying the tabs which are reordered.
Save the index when reordering begins. `dragTabHeaderStartIndex`
Save the index when tab is dropped. `dragTabHeaderIndex`
If the index are same then reordering of tabs is NOT needed.
If the index are NOT same then the tabs from `dragTabHeaderStartIndex` to `dragTabHeaderIndex` are reordered.

This fix is specific to TabPane reordering. No other tests/behavior should be affected.
Added a new system test.


 - 835e7aa8: [WIP]8237453: [TabPane] Incorrect arrow key traversal through tabs after reordering

Changes: https://git.openjdk.java.net/jfx/pull/106/files
 Webrev: https://webrevs.openjdk.java.net/jfx/106/webrev.00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8237453
  Stats: 311 lines in 2 files changed: 300 ins; 4 del; 7 mod
  Patch: https://git.openjdk.java.net/jfx/pull/106.diff
  Fetch: git fetch https://git.openjdk.java.net/jfx pull/106/head:pull/106

PR: https://git.openjdk.java.net/jfx/pull/106

More information about the openjfx-dev mailing list