SwiftUI - How to remove huge space on left of List while editing

Viewed 77

To enable rearranging items in my List, I added an EditButton() and attached the onMove modifier. Here's my code:

struct ContentView: View {
    @State var names = ["Adam", "Bob", "Cole", "Dad", "Ella"]
    
    var body: some View {
        NavigationView {
            List {
                ForEach(names, id: \.self) { name in
                    Text(name)
                }
                .onMove { names.move(fromOffsets: $0, toOffset: $1) }
            }
            .toolbar { EditButton() }
        }
    }
}

Once I press the "Edit" button, I can reorder the items. However, a huge space appears on the left side of each row.

Not editing Edit button pressed
Names stacked vertically, Edit button inside navigation bar Names stacked vertically with huge space on left, Done button inside navigation bar

How do I get rid this space?

I suspect that it's placeholder space for a delete button, but I don't need a delete button.

0 Answers
Related