Under some circumstances, it is possible that the TableCell indices do not match with their TableRow index.
This does not happen often, but there is a scenario where it can be reproduced 100%.
Check the attached source.
1. Start the App
2. Scroll to the bottom (completely)
3. Now click the 'Re-Set items' Button
4. Note that you can not select LASTITEM anymore, when you click on the cell (so inbetween the column bounds)
5. The "0" item can be selected
The following happens under the hood:
- We scroll to the bottom, the last TableRow has the index 60, the underlying TableCells as well
- Now we re-set the Items, there is one item that is in the previous items list and in the new one
- JavaFX will now reindex all cells since the items completely changed
- The TableRow with index 60 will now get the index 1. This does not trigger an update of the underlying TableCells.
- The TableRow will now also update the Item. The Item is in this case the SAME ("LASTITEM" before, "LASTITEM" after)
-> This will therefore not trigger the cell update, so the underlying TableCells will not update the index ever (they still think they are at index 60)
This behavior is deterministic, but is hard to reproduce other than my example since we need to be 'lucky' that the cell is reused exactly where the item is the same as before, just the index changed.
NOTE: applies to TableView and TreeTableView.
This does not happen often, but there is a scenario where it can be reproduced 100%.
Check the attached source.
1. Start the App
2. Scroll to the bottom (completely)
3. Now click the 'Re-Set items' Button
4. Note that you can not select LASTITEM anymore, when you click on the cell (so inbetween the column bounds)
5. The "0" item can be selected
The following happens under the hood:
- We scroll to the bottom, the last TableRow has the index 60, the underlying TableCells as well
- Now we re-set the Items, there is one item that is in the previous items list and in the new one
- JavaFX will now reindex all cells since the items completely changed
- The TableRow with index 60 will now get the index 1. This does not trigger an update of the underlying TableCells.
- The TableRow will now also update the Item. The Item is in this case the SAME ("LASTITEM" before, "LASTITEM" after)
-> This will therefore not trigger the cell update, so the underlying TableCells will not update the index ever (they still think they are at index 60)
This behavior is deterministic, but is hard to reproduce other than my example since we need to be 'lucky' that the cell is reused exactly where the item is the same as before, just the index changed.
NOTE: applies to TableView and TreeTableView.
- relates to
-
JDK-8095357 [TableView] Cell selection dont work properly
-
- Resolved
-
-
JDK-8115269 TableRow "item" property is being updated out of order
-
- Resolved
-
- links to
-
Commit(master) openjdk/jfx/b0e763c1
-
Review(master) openjdk/jfx/1635