AllanJuenemann / CalendarView

UICalendarView for SwiftUI
MIT License
49 stars 6 forks source link

Providing a default value for `selection` parameter causes view to be unscrollable #3

Open bstillitano opened 1 month ago

bstillitano commented 1 month ago

Providing anything except nil as the default value for a selection binding, will cause the view to be non scrollable until the user taps another date.

AllanJuenemann commented 2 weeks ago

@bstillitano Sorry for the slow response.

I tried to reproduce the issue you described. See below. But all versions work fine (tested with version 2.1.0 on iOS 17.5)

struct ContentView: View {
    @State private var selection: DateComponents?

    var body: some View {
        CalendarView(selection: $selection)
    }
}
struct ContentView: View {
    @State private var selection: DateComponents? = DateComponents(year: 2024, month: 8, day: 16)

    var body: some View {
        CalendarView(selection: $selection)
    }
}
struct ContentView: View {
    @State private var selection: DateComponents? 

    var body: some View {
        CalendarView(selection: $selection)
            .onAppear {
                selection = DateComponents(year: 2024, month: 8, day: 16)
            }
    }
}

Would you be able to share a code sample with me that causes the scrolling issues you're experiencing?