Tuesday, February 13, 2024

Dragging From a List With SwiftUI

Marco Arment:

I wish so badly that SwiftUI’s .onMove supported multiple-item selection in a List.

I should never need to tell my customers, “That was too difficult to achieve in SwiftUI, so that feature is gone.”

It’s scary reading stuff like this because, glancing at the API, the source is an IndexSet, so it seems like it was designed to handle multiple items. How are you supposed to know ahead of time that this doesn’t work? I was hoping to see someone reply, telling Arment what he was doing wrong, but instead there were two links to forum threads about list dragging being broken.

Tim Schmitz:

This category of problem still really concerns me about the future of Apple’s UI frameworks. There are some things that were possible in UIKit that just aren’t in SwiftUI, and Apple doesn’t seem too bothered by some of them.

This is basic stuff, not obscure features. The iOS and macOS interfaces make heavy use of lists and tables. And SwiftUI was introduced almost 5 years ago.


SwiftUI 5 feels mostly feature complete on the iOS side, but List keeps being hard for Apple to get right it seems. In terms of onDelete and onMove, they have improved a bit over the years but still problematic.

On the Mac side, I periodically take a look at Shortcuts to see how it’s doing. It still doesn’t support dragging and dropping shortcuts from the list into a folder in the sidebar (even if you only drag one). It does let me re-order a multiple selection, though it also lets me try when a sort is in effect, which of course doesn’t work. Whenever I click on something in the sidebar it loses the sort and goes back to the manual ordering. I don’t know what the thinking was here.


Update (2024-02-14): Rhett Rogers:

Every time I attempt to use a SwiftUI List, I think it is perfect.

Then I actually have to make something real and it almost always falls short whenever I have to do anything with custom colors or animations. And I fall back to a ScrollView { VStack {} }.

Helge Heß:

It would be ok if it would just affect customization, I just want the stuff that is builtin. But it’s flickering and has all sorts of other weird side effects (transitions etc).


I was converting a like 3y old SwiftUI app to List end of last year assuming that it should have gotten OK by now. Still the same mess (same for LazyVStack fwiw, so as you went back to ScrollView + non-lazy VStack).

2 Comments RSS · Twitter · Mastodon

And this from the company that popularized the entire concept of drag and drop. This is what worries me about the way they are bringing iOS to the Mac. They are kind of creating the same problem for themselves that Windows has, with too many different ways to do things, losing the benefits of the past but not actually gaining much with the new ways.

> I should never need to tell my customers, “That was too difficult to achieve in SwiftUI, so that feature is gone.”

I agree so don’t use SwiftUI. I think they’ve had enough time here. I’m convinced we are going to get stuck with inferior tools if we don’t push back.

Don’t promote SwiftUI. Don’t blog about SwiftUI. Blog about UIKit. Write UIKit tutorials and keep UIKit relevant. SwiftUI will only “succeed” if developers let it. The things SwiftUI makes easier aren’t worth the tradeoffs.

Leave a Comment