List items do not appear to be moveable when they are contained within a popover on Mac Catalyst running on macOS Sonoma. Dragging and dropping a list item simply returns it to its original location, and onMove(preform:) is not called. The same happens using the drag handles with an EditButton() or .environment(\.editMode, .constant(.active)).
Below is a reproducible sample which, to my knowledge, worked as expected on Ventura. It also currently works as expected on iPad. Changing the popover to a sheet makes it work on Mac Catalyst, but then, the view takes up a lot of unnecessary space.
Does anyone have any good workarounds for this issue?
struct ContentView: View {
@State private var isShowingPopover = false
@State private var items = ["one", "two", "three"]
var body: some View {
Button("Show Popover") {
isShowingPopover = true
}
.popover(isPresented: $isShowingPopover) {
List {
ForEach(items, id: \.self) { item in
Text(item)
}
.onMove { fromOffsets, toOffset in
items.move(fromOffsets: fromOffsets, toOffset: toOffset)
}
}
.frame(minWidth: 300, minHeight: 270)
}
}
}
Post
Replies
Boosts
Views
Activity
When using searchable with an empty text query, entering and exiting a destination view causes the search to dismiss. This does not happen if there is a query in the search bar. On iOS 15, the destination view also auto-dismisses when doing this. This appears to happen on iPhone, iPad, and Mac Catalyst.
Use Case:
I am trying to use both search and navigation in the sidebar. As is shown below, I have a List of NavigationLinks that is shown when the user is searching. Entering a link when there is an empty query in the search bar causes the search to dismiss upon exiting the destination view.
Does anyone have any suggestions or workarounds for this issue?
struct ContentView: View {
@State private var query = ""
private var sidebar: some View {
Sidebar()
.searchable(text: $query)
}
private var detail: some View {
Text("Placeholder for nav split detail pane.")
}
var body: some View {
if #available(iOS 16, *) {
NavigationSplitView {
sidebar
} detail: {
detail
}
} else {
NavigationView {
sidebar
detail
}
}
}
}
struct Sidebar: View {
@Environment(\.isSearching) private var isSearching
var body: some View {
if !isSearching {
Text("Sidebar Content")
.navigationTitle("Example")
} else {
List {
NavigationLink {
Text("Detail View")
} label: {
Text("Search Result")
}
}
}
}
}