RFR: 8193442: Removing TreeItem from a TreeTableView sometime changes selectedItem [v3]

Ajit Ghaisas aghaisas at openjdk.java.net
Fri Apr 22 10:58:40 UTC 2022


On Thu, 21 Apr 2022 08:37:11 GMT, Jose Pereda <jpereda at openjdk.org> wrote:

>> This PR fixes JDK-[8193442](https://bugs.openjdk.java.net/browse/JDK-8193442), but also [JDK-8187596](https://bugs.openjdk.java.net/browse/JDK-8187596), and verifies that the tests mentioned in [JDK-8088157](https://bugs.openjdk.java.net/browse/JDK-8088157) are working (with a minor fix).
>> 
>> When removing an item that is below the selected item from TreeTableView or TreeView controls the selection and/or focus was wrongly changed in some occasions, because a shift in the selection was applied.
>> 
>> This PR adds a method to ControlUtils to get the index of the sibling that is selected/focused or contains the descendant item with the current selection/focus. 
>> 
>> This index is required to compare properly if the selected/focus item is above or below the item that was removed, by comparing the indices of siblings.
>> 
>> Tests have been added to TreeViewTest and TreeTableViewTest based on the existing tests on JDK-8193442 and JDK-8187596. The four tests fail without this PR, pass with it.
>> 
>> In the process, I noticed that the ignored tests referred from JDK-8088157 were already passing, after removing some obsolete asserts, even without this PR.
>
> Jose Pereda has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains four commits:
> 
>  - Fix spacing in tests
>  - Merge branch 'master' into 8193442-treeitemselection
>  - Merge branch 'master' into 8193442-treeitemselection
>  - Don't shift selection/focus if item is below removed element

Looks good to me.
Apart from the bug id in title, you can use `/issue` command to list additional issues this PR fixes.

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

Marked as reviewed by aghaisas (Reviewer).

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


More information about the openjfx-dev mailing list