SwiftUI, List items reordering issue (iOS 16)

Hello,

On iOS 15, I had a feature who allow the user to reorder some items inside of a list. Some view was not allowed to move (I use the modifier .moveDisabled for this behavior).

In iOS 15, everything was working fine : I'm able to reorder items inside of the list (only for those who was allowed to be moved).

But in iOS 16, I have a strange behavior : I still can reorder items, but if two items are not allowed to be reordered, I can't move any items between them.

Here is the example :

iOS 15 :

iOS 16 :

For this feature, I only use:

  • standard SwiftUI List.
  • .environment(\.editMode, .constant(.active)) (the view should always be editable).
  • .moveDisabled() to allow items to be moved.

No custom element here, everything is SwiftUI framework.

What am I doing wrong?

Thanks,

Alexandre

I see the same behaviour and have filed a bug as FB11680421 (the autogenerated link is missing the final 1) .

Here's some example code to demonstrate the problem. This works in iOS 15 but not iOS 16.

import SwiftUI

struct MoveDisabled: View {
    @State private var users = ["user1", "user2", "user3", "user4"]

    var body: some View {
        List {
            ForEach(users, id: \.self) { user in
                Text(user)
                    .moveDisabled(user == "user2" || user == "user3")
            }
            .onMove { source, index in
                self.users.move(fromOffsets: source, toOffset: index)
            }
        }
        .environment(\.editMode, .constant(.active))
    }
}

struct MoveDisabled_Previews: PreviewProvider {
    static var previews: some View {
        MoveDisabled()
    }
}

has anyone found a workaround for this issue? it's really a blocker. Plus, in iOS16 the move behaviour looks more like a drag now since it is possible to drag a row not only vertically but also horizontally... which looks weird

Same! No workaround yet?

Place .moveDisabled() as last view modifier (or somewhere towards the end of applied modifiers) and then it will work. I have found out this by accident as in my app in some places .moveDisabled() was working while in other places it was not. I guess there's some view modifier that breaks .moveDisabled() if applied after .moveDisabled().

Doesn't work for me either. Any other ideas on how to fix this peculiar behaviour?

SwiftUI, List items reordering issue (iOS 16)
 
 
Q