Skip to content
Open
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
33 changes: 5 additions & 28 deletions maui/src/Picker/SfDateTimePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ public class SfDateTimePicker : PickerBase, IParentThemeElement, IThemeElement
/// </summary>
int _selectedIndex;

/// <summary>
/// Holds the header changed or not
/// </summary>
bool _isCurrentPickerViewChanged = false;

#endregion

#region Bindable Properties
Expand Down Expand Up @@ -1048,20 +1043,10 @@ void OnPickerSelectionIndexChanged(object? sender, PickerSelectionChangedEventAr
{
if (_selectedIndex == 0)
{
if (IsScrollSelectionAllowed())
{
ResetDateTimeOnViewChange();
}

OnDatePickerSelectionIndexChanged(e);
}
else
{
if (IsScrollSelectionAllowed())
{
ResetDateTimeOnViewChange();
}

OnTimePickerSelectionIndexChanged(e);
}
}
Expand Down Expand Up @@ -1868,18 +1853,6 @@ void UpdateColumnsSelectedItem()
_meridiemColumn.SelectedItem = PickerHelper.GetSelectedItemDefaultValue(_meridiemColumn);
}

/// <summary>
/// Need to reset the current selected date or time value without okay button click.
/// </summary>
void ResetDateTimeOnViewChange()
{
if (_internalSelectedDateTime != null && _isCurrentPickerViewChanged)
{
_internalSelectedDateTime = null;
_isCurrentPickerViewChanged = false;
}
}

/// <summary>
/// Method to generate the day column with items source and selected index based on format.
/// </summary>
Expand Down Expand Up @@ -2293,7 +2266,6 @@ protected override void OnHeaderButtonClicked(int index)
}

_selectedIndex = index;
_isCurrentPickerViewChanged = true;
if (_selectedIndex == 0)
{
ResetDateColumns();
Expand Down Expand Up @@ -2425,6 +2397,11 @@ protected override void OnCancelButtonClicked(EventArgs e)
if (SelectedDate != null)
{
// Update the selected index in the UI to reflect the selected date
if (_internalSelectedDateTime != null)
{
_internalSelectedDateTime = null;
}

UpdateSelectedIndex(SelectedDate);
}
else
Expand Down