Skip to content

EditButton stops working just by adding the package (retroactive Binding Equatable) #11

@mrsunx

Description

@mrsunx

Hi, thanks for the package!

I ran into a SwiftUI issue where EditButton stops toggling edit mode simply by adding this package, even if I don’t use any of its views.

Minimal repro:

var body: some Scene {
    WindowGroup {
        NavigationStack {
            NavigationLink(destination: {
                List {
                    Text("Row")
                }
                .toolbar {
                    EditButton()
                }
            }, label: {
                Text("Push")
            })
        }
    }
}

When the package is included, EditButton doesn’t change the edit state anymore (no visible effect).
If I remove the package, it works as expected.

I tracked it down to this code:

extension Binding: @retroactive Equatable where Value: Equatable {
    public static func == (lhs: Binding<Value>, rhs: Binding<Value>) -> Bool {
        lhs.wrappedValue == rhs.wrappedValue
    }
}

Even in a project without this package, adding the above extension alone reproduces the same issue (EditButton state no longer toggles).

This retroactive conformance seems to affect SwiftUI’s internal diffing/state updates.

Would you consider removing this global conformance or scoping it to a custom wrapper type instead?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions