It's insane than with List you can't have multiple .contextMenu for one row… #SwiftUI

@dimillian that’s an interesting API design problem! Could you file a Feedback with the use case? No need for a sample, but a screenshot would help. That would help us prioritize/design the right thing. If you file, let me know the number and I’ll make sure it goes to the right person.

@curtclifton Imagine a row with many images in an horizontal scrollView for example. Or even a LazyVGrid in one single row. You can't add actions to individual images (like select/edit/remove, etc.) because the contextMenu selects all the row.

@alpennec @curtclifton It’s just feel like a bug at this point. It doesn’t make sense that a View in a List take one random .contextMenu but not the other. Before I swapped to List, I was using LazyVStack + ScrollView and it was perfectly fine to have one .contextMenu per view in it.

@dimillian @alpennec it’s by design and falls out of the fact that buttons in List rows highlight the whole row. A single context menu per row is the 95% use case, so the simplest API should do that. If you file a feedback, I’d love to understand how you’d expect this to be spelled. Thanks!

@curtclifton @alpennec I’ll fill a feedback about it, but also I think right now it’s counter intuitive. I except views in List to work like views in any other container. If views have .contextMenu, it should work. Same for Buttons and NavigationLink. I do like a lot of the List auto backed behaviour which come directly from UIKit but it also still lack customisation. And can’t use ScrollView + LazyVStack for non opinionated container due to performances problems.

Follow

@dimillian @curtclifton +1 this. I have a List with a Grid containing featured items in the first row (similar to the Reminders app). The menu modifier is applied to the whole row. This isn't the case with other touch states like hover and on press, which behave as expected. Filed a feedback too, if helpful (FB12011885)

Sign in to participate in the conversation
The Not So Big Company

The home of The Not So Big Company on Mastodon.