Skip to content

Commit 1a358f4

Browse files
authored
WheelPicker Editable Fix (#33)
1 parent 9c17e4e commit 1a358f4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

CodeBeam.MudExtensions/Components/DateWheelPicker/MudDateWheelPicker.razor.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ public partial class MudDateWheelPicker : MudBaseInput<DateTime?>
1717
new CssBuilder("mud-input-input-control")
1818
.AddClass(Class)
1919
.Build();
20-
20+
DateTime dt;
2121
protected override void OnInitialized()
2222
{
2323
Converter = new MudBlazor.Converter<DateTime?, string>()
2424
{
2525
SetFunc = x => x?.ToString(DateFormat),
26+
GetFunc = x => DateTime.TryParseExact(x, DateFormat, null, System.Globalization.DateTimeStyles.None, out dt) == true ? dt : null,
2627
};
2728
}
2829

@@ -213,13 +214,14 @@ protected override void OnInitialized()
213214

214215
protected async Task UpdateValueAsync(bool updateText = true)
215216
{
217+
var _backUpValue = Value;
216218
try
217219
{
218220
await SetValueAsync(new DateTime(_year, _month, _day, _hour, _minute, _second), updateText);
219221
}
220-
catch (Exception)
222+
catch
221223
{
222-
//ignore
224+
await SetValueAsync(_backUpValue, updateText);
223225
}
224226
}
225227

@@ -256,9 +258,9 @@ public async Task CloseMenu(bool submit)
256258
}
257259
}
258260

259-
protected void HandleOnBlur()
261+
protected async Task HandleOnBlur()
260262
{
261-
SetTextAsync(InputReference.Text, true);
263+
await SetTextAsync(InputReference.Text, true);
262264
}
263265

264266
protected async Task HandleAdornmentClick()

0 commit comments

Comments
 (0)