git.iko.soy/parseable-macos
on master help sign in
Fix custom time range not applied when popover dismissed by clicking outside
0ebbd03iko
ParseableViewer/Views/TimeRangePicker.swift+14−2
@@ -37,9 +37,20 @@ struct TimeRangePicker: View {
37 // inverted or zero-width range selected (the menu already set
37 // inverted or zero-width range selected (the menu already set
38 // `option == .custom`). Sanitize on close so a backwards range can
38 // `option == .custom`). Sanitize on close so a backwards range can
39 // never reach a query.
39 // never reach a query.
40+ guard !isShown else { return }
40− if !isShown && customEnd <= customStart {
41+ if customEnd <= customStart {
41 customEnd = customStart.addingTimeInterval(3600)
42 customEnd = customStart.addingTimeInterval(3600)
42 }
43 }
44+ // Commit on *every* close path, not just the "Done" button. Closing
45+ // the popover by clicking outside is the common dismissal gesture;
46+ // without this the picker reads "Custom" while results still reflect
47+ // the previously selected preset, since QueryView only re-queries on
48+ // `timeRangeOption` changes (which it skips for `.custom`) — never on
49+ // the custom dates. Done sets `showCustomPicker = false` and lets this
50+ // handler do the single commit, so there's no double-query.
51+ if option == .custom {
52+ onCommit?()
53+ }
43 }
54 }
44 .popover(isPresented: $showCustomPicker) {
55 .popover(isPresented: $showCustomPicker) {
45 VStack(spacing: 12) {
56 VStack(spacing: 12) {
@@ -88,8 +99,9 @@ struct TimeRangePicker: View {
88 Spacer()
99 Spacer()
89
100
90 Button("Done") {
101 Button("Done") {
102+ // Just close — the `showCustomPicker` change handler is the
103+ // single commit point for all close paths (Done + click-out).
91 showCustomPicker = false
104 showCustomPicker = false
92− onCommit?()
93 }
105 }
94 .buttonStyle(.borderedProminent)
106 .buttonStyle(.borderedProminent)
95 .disabled(customEnd <= customStart)
107 .disabled(customEnd <= customStart)