Skip to content

Commit

Permalink
Fixing auto suggest today could suggest an old date - Related to #136
Browse files Browse the repository at this point in the history
  • Loading branch information
DamascenoRafael committed May 14, 2023
1 parent 4e94312 commit d50c617
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions reminders-menubar/Views/FormNewReminderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ struct FormNewReminderView: View {
}
}
.padding(10)
.onChange(of: rmbReminder.title) { newValue in
.onChange(of: rmbReminder.title) { [oldValue = rmbReminder.title] newValue in
withAnimation(.easeOut(duration: 0.3)) {
isShowingDueDateOptions = !newValue.isEmpty
}
if newValue.isEmpty {
rmbReminder = newRmbReminder()

// NOTE: When the first character is typed we re-instantiate RmbReminder to ensure the date is as expected.
if oldValue.isEmpty && newValue.count == 1 {
rmbReminder = newRmbReminder(withTitle: newValue)
}
}
.onAppear {
Expand All @@ -97,8 +99,10 @@ struct FormNewReminderView: View {
}
}

func newRmbReminder() -> RmbReminder {
return RmbReminder(hasDueDate: userPreferences.autoSuggestToday)
func newRmbReminder(withTitle title: String = "") -> RmbReminder {
var rmbReminder = RmbReminder(hasDueDate: userPreferences.autoSuggestToday)
rmbReminder.title = title
return rmbReminder
}

func createNewReminder() {
Expand Down

0 comments on commit d50c617

Please sign in to comment.