Skip to content

FB23686002: SwiftUI List: moving an item between List sections using a swipeAction doesn't animate correctly the row in iOS 26 and iOS 27 (works as expected in iOS 18) #819

Description

@alpennec

Submission Date

2025-07-11

Status

Open

Area

SwiftUI

Operating System Version

iOS 26

Type

Incorrect/Unexpected Behavior

Description

Hello,

The row animation when moving an item between section in a List using a swipeAction is incorrect in iOS 26 and iOS 27.
It looks very nice in iOS 18.

Use case: use a swipeAction to pin a content like in Apple Notes.

See my related feedback: FB23661327

Thank you,
Regards,

struct ListSectionsSwipeActionsSingle: View {
    @Observable
    class Item: Identifiable {
        init(
            id: Int,
            isFavorite: Bool
        ) {
            self.id = id
            self.isFavorite = isFavorite
        }
        
        var id: Int
        var isFavorite: Bool
    }
    
    @State private var items: [Item] = [
        .init(id: 0, isFavorite: false),
        .init(id: 1, isFavorite: false),
        .init(id: 2, isFavorite: true),
        .init(id: 3, isFavorite: false),
        .init(id: 4, isFavorite: false),
        .init(id: 5, isFavorite: true),
        .init(id: 6, isFavorite: false),
        .init(id: 7, isFavorite: true),
        .init(id: 8, isFavorite: true),
        .init(id: 9, isFavorite: false),
        .init(id: 10, isFavorite: false),
    ]
    
    private var favorites: [Item] {
        return items.filter(\.isFavorite)
    }
    
    private var notFavorites: [Item] {
        return items.filter { return !$0.isFavorite }
    }
    
    var body: some View {
        NavigationStack {
            List {
                if !favorites.isEmpty {
                    Section("Favorites") {
                        ForEach(favorites) { rowID in
                            makeRow(item: rowID)
                        }
                    }
                }

                Section {
                    ForEach(notFavorites) { rowID in
                        makeRow(item: rowID)
                    }
                }
            }
        }
    }
    
    private func makeRow(item: Item) -> some View {
        Button {
            favoriteUnfavorite(item: item)
        } label: {
            HStack {
                Text(item.id.formatted())
                    .font(.title.weight(.semibold))

                Spacer()

                if item.isFavorite {
                    Image(systemName: "star.fill")
                }
            }
        }
        .swipeActions {
            Button {
                favoriteUnfavorite(item: item)
            } label: {
                Label(
                    item.isFavorite ? "Favorite" : "Undo",
                    systemImage: "star"
                )
                .symbolVariant(item.isFavorite ? .slash : .none)
            }
            .tint(.green)
        }
    }

    private func favoriteUnfavorite(item: Item) {
        withAnimation(.bouncy) {
            item.isFavorite.toggle()
        }
    }
}

#Preview {
    ListSectionsSwipeActionsSingle()
}

Keywords

No response

Prerequisites

  • The title follows the format FB<number>: <title>
  • I will keep this issue updated with Apple's responses

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions