Skip to content

Conversation

@kaascevich
Copy link
Contributor

This allows setting menu items to always appear in the order you write them in for backends that change the sort order depending on where the menu is opened from (currently only UIKit).

Copy link
Collaborator

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some documentation changes. Implementation looks good

@stackotter
Copy link
Collaborator

Tested locally and all seems to work well. For future reference;

import DefaultBackend
import SwiftCrossUI

@main
struct TestApp: App {
    @State var fixedOrder = false

    var body: some Scene {
        WindowGroup {
            VStack {
                Menu("Top button") {
                    Button("Item 1") {}
                    Button("Item 2") {}
                    Button("Item 3") {}
                    Button("Item 4") {}
                }.menuOrder(fixedOrder ? .fixed : .priority)

                Spacer()

                Toggle("Use fixed order", isOn: $fixedOrder)

                Spacer()

                Menu("Bottom button") {
                    Button("Item 1") {}
                    Button("Item 2") {}
                    Button("Item 3") {}
                    Button("Item 4") {}
                }.menuOrder(fixedOrder ? .fixed : .priority)
            }.padding()
        }
    }
}

@stackotter stackotter merged commit 41bb742 into moreSwift:main Jan 9, 2026
11 checks passed
@kaascevich kaascevich deleted the menu-order branch January 9, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants