Open Bug 2088766 Opened 23 days ago

Look up the dragged item by key in InteractableGrid instead of caching its index

Categories

(Firefox for Android :: General, task)

All
Android
task

Tracking

()

People

(Reporter: petru, Unassigned)

References

Details

InteractableGrid keeps the index of the dragged item in draggedItem.index, and refreshes it in handleReorderingModeOnDrag by calling copyWithNewIndex right after doReorder. The refresh reads gridState.layoutInfo before the grid is laid out again with the item moved, so it stores the index the item had before the move. The cached index is therefore always one reorder behind.

It is read by:

  • doReorder, which compares it with gridState.firstVisibleItemIndex to decide whether to scroll;
  • onDrag, which passes it to computeItemOffset;
  • resetState, which passes it to computeItemOffset to start the drop animation.

computeItemOffset looks up the item at that index, which after a live reorder can be another item.

The same problem was found for InteractableList in bug 2086549, where the item is now found by its key and copyWithNewIndex is gone for lists. InteractionState.Grid.getLazyGridItemInfo already finds the item by key, so the grid can do the same and drop the index refresh. Check whether a drop animation or the scroll check misbehave in the tabs tray when reordering with live reorder enabled.

You need to log in before you can comment on or make changes to this bug.