Skip to content

Commit 9560247

Browse files
authored
Cleanup & Try (#374)
1 parent 2ae84bc commit 9560247

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ public partial class MudChipField<T> : MudTextFieldExtended<T>
110110
/// <returns></returns>
111111
protected async Task HandleKeyDown(KeyboardEventArgs args)
112112
{
113-
114-
if (args.Key == Delimiter.ToString() && _internalValue != null)
113+
var result = args.Code == "Space" ? " " : args.Key;
114+
if (result == Delimiter.ToString() && _internalValue != null)
115115
{
116116
await SetChips();
117117
StateHasChanged();

CodeBeam.MudBlazor.Extensions/Components/CodeInput/MudCodeInput.razor.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public MudCodeInput() : base(new DefaultConverter<T>()) { }
3737
/// </summary>
3838
[Parameter]
3939
[Category(CategoryTypes.FormComponent.Behavior)]
40-
public string ClassInput { get; set; }
40+
public string? ClassInput { get; set; }
4141

4242
/// <summary>
4343
/// Type of the input element. It should be a valid HTML5 input type.
@@ -46,14 +46,14 @@ public MudCodeInput() : base(new DefaultConverter<T>()) { }
4646
[Category(CategoryTypes.FormComponent.Behavior)]
4747
public InputType InputType { get; set; } = InputType.Text;
4848

49-
private T _theValue;
49+
private T? _theValue;
5050

5151
/// <summary>
5252
/// The value of the input.
5353
/// </summary>
5454
[Parameter]
5555
[Category(CategoryTypes.FormComponent.Behavior)]
56-
public T Value
56+
public T? Value
5757
{
5858
get => _theValue;
5959
set
@@ -72,7 +72,7 @@ public T Value
7272
/// </summary>
7373
[Parameter]
7474
[Category(CategoryTypes.FormComponent.Behavior)]
75-
public EventCallback<T> ValueChanged { get; set; }
75+
public EventCallback<T?> ValueChanged { get; set; }
7676

7777
private int _count;
7878
/// <summary>
@@ -167,6 +167,10 @@ protected async Task HandleKeyDown(KeyboardEventArgs arg)
167167
}
168168

169169
private int _lastFocusedIndex = 0;
170+
/// <summary>
171+
///
172+
/// </summary>
173+
/// <param name="count"></param>
170174
protected void CheckFocus(int count)
171175
{
172176
_lastFocusedIndex = count;
@@ -242,17 +246,22 @@ public async Task SetValue()
242246
await ValueChanged.InvokeAsync(Value);
243247
}
244248

245-
public async Task SetValueFromOutside(T value)
249+
/// <summary>
250+
///
251+
/// </summary>
252+
/// <param name="value"></param>
253+
/// <returns></returns>
254+
public async Task SetValueFromOutside(T? value)
246255
{
247-
string val = Converter.Set(value);
248-
if (Count < val.Length)
256+
string? val = Converter.Set(value);
257+
if (Count < val?.Length)
249258
{
250259
val = val.Substring(0, Count);
251260
}
252261
Value = Converter.Get(val);
253262
for (int i = 0; i < Count; i++)
254263
{
255-
if (i < val.Length)
264+
if (i < val?.Length)
256265
{
257266
await _elementReferences[i].SetText(val[i].ToString());
258267
}

0 commit comments

Comments
 (0)