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

Kevin Rushforth kcr at openjdk.java.net
Wed Feb 5 23:31:38 UTC 2020


On Wed, 5 Feb 2020 11:07:39 GMT, Ambarish Rapte <arapte at openjdk.org> wrote:

> Issue: 
> 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.
> 
> Cause:
> 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`.
> 
> Fix:
> 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.
> 
> Verification:
> This fix is specific to TabPane reordering. No other tests/behavior should be affected.
> Added a new system test.

Looks good.

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

Marked as reviewed by kcr (Lead).

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


More information about the openjfx-dev mailing list