Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c7da25d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix issue where widget disappears when reordering" into main

parents c7a89b80 8e08e352
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -179,11 +179,18 @@ internal constructor(
        val targetItem =
            if (communalWidgetResizing()) {
                state.layoutInfo.visibleItemsInfo.findLast { item ->
                    val lastVisibleItemIndex = state.layoutInfo.visibleItemsInfo.last().index
                    val itemBoundingBox = IntRect(item.offset, item.size)
                    draggingItemKey != item.key &&
                        contentListState.isItemEditable(item.index) &&
                        (draggingBoundingBox.contains(itemBoundingBox.center) ||
                            itemBoundingBox.contains(draggingBoundingBox.center))
                            itemBoundingBox.contains(draggingBoundingBox.center)) &&
                        // If we swap with the last visible item, and that item doesn't fit
                        // in the gap created by moving the current item, then the current item
                        // will get placed after the last visible item. In this case, it gets
                        // placed outside of the viewport. We avoid this here, so the user
                        // has to scroll first before the swap can happen.
                        (item.index != lastVisibleItemIndex || item.span <= draggingItem.span)
                }
            } else {
                state.layoutInfo.visibleItemsInfo