Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selected Date bug fix #104

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Calendar.Plugin/Shared/Controls/Calendar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ private static void OnSelectedDateChanged(BindableObject bindable, object oldVal
var dateToSet = (DateTime?)newValue;

control.SetValue(SelectedDateProperty, dateToSet);
if (!control._isSelectingDates)
if (!control._isSelectingDates || control.monthDaysView.CurrentSelectionEngine is SingleSelectionEngine)
{
if (dateToSet.HasValue)
control.SetValue(SelectedDatesProperty, new List<DateTime> { dateToSet.Value });
Expand Down
3 changes: 3 additions & 0 deletions src/Calendar.Plugin/Shared/Controls/RangeSelectionCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,18 @@ private static void OnSelectedStartDateChanged(BindableObject bindable, object o
var rangeSelectionCalendar = (RangeSelectionCalendar)bindable;
if (!rangeSelectionCalendar._isSelectionDatesChanging)
{
rangeSelectionCalendar._isSelectionDatesChanging = true;
rangeSelectionCalendar._selectionEngine.SelectDateRange((DateTime?)newValue);
rangeSelectionCalendar.SelectedDates = rangeSelectionCalendar._selectionEngine.GetDateRange();
rangeSelectionCalendar._isSelectionDatesChanging = false;
}
}
private static void OnSelectedEndDateChanged(BindableObject bindable, object oldValue, object newValue)
{
var rangeSelectionCalendar = (RangeSelectionCalendar)bindable;
if (!rangeSelectionCalendar._isSelectionDatesChanging)
{
rangeSelectionCalendar._isSelectionDatesChanging = true;
rangeSelectionCalendar._selectionEngine.SelectDateRange((DateTime?)newValue);
rangeSelectionCalendar.SelectedDates = rangeSelectionCalendar._selectionEngine.GetDateRange();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void ISelectionEngine.UpdateDateSelection(List<DateTime> datesToSelect)

internal List<DateTime> SelectDateRange(DateTime? newSelected)
{
if (_rangeSelectionStartDate is null || !Equals(_rangeSelectionStartDate, _rangeSelectionEndDate))
if (_rangeSelectionStartDate is null || !Equals(_rangeSelectionStartDate, _rangeSelectionEndDate) || newSelected is null)
SelectFirstIntervalBorder(newSelected);
else
SelectSecondIntervalBorder(newSelected);
Expand Down