Removed unnecessary SatateHasChanged() on Textinput

pull/7/head
stm 2 years ago
parent e0c0e3dd68
commit 1eb7202561

@ -3,112 +3,39 @@
<h1 style="text-align:center;">Component Sandbox</h1>
<p>ValueDouble: @inputValueDouble.ToString()</p>
<p>ValueInt: @inputValueInt.ToString()</p>
<p>ValueText: @inputValueText</p>
<p>SimpleSelectValue: @SelectedItemValue</p>
<InputNumber
Clearable="false"
DisableMouseWheel="false"
Disabled="false"
Readonly="false"
Placeholder="Double"
Label="Double"
Required="true"
Step="0.000516"
DecimalPlaces=5
Class="m-2"
@bind-Value="@inputValueDouble">
</InputNumber>
<InputNumber
Clearable="true"
DisableMouseWheel="false"
Disabled="false"
Readonly="false"
Placeholder="Double"
Label="Integer"
Required="true"
Step="0.001"
DecimalPlaces="2"
Class="m-4"
@bind-Value="@inputValueInt">
</InputNumber>
<InputText
Label="String"
Required="true"
ErrorText="@errorText"
@bind-Value="@inputValueText">
</InputText>
<InputText
Label="Password"
IsPassword="true"
Required="true"
ErrorText="@errorText"
@bind-Value="@inputValueText">
</InputText>
<p>SelectedValue: @SelectedValue.ToString()</p>
<SimpleSelect
Label="Simple Select"
ValueType="string"
@bind-Value="@SelectedItemValue"
Items="@SelectFieldItems">
</SimpleSelect>
Items="@items"
Label="Simple select"
@bind-Value=@SelectedValue
/>
@code {
int SelectedValue;
List<SelectItem<string>> SelectFieldItems = new();
string SelectedItemValue = "";
List<int> items;
int counter { get; set; } = 0;
private string _inputText = string.Empty;
string inputValueText
{
get
private void FillItemsList()
{
return _inputText;
}
set
{
if (value.Length > 0) errorText = "Error!!!";
else errorText = "";
_inputText = value;
StateHasChanged();
}
}
double inputValueDouble = 12.756;
int inputValueInt = 12;
if (items is null) items = new();
DateTime inputValueDate = DateTime.Now.AddDays(-10);
Random random = new Random(DateTime.Now.Millisecond);
public void CounterIncrement()
for (int i = 0; i < 10; i++)
{
counter++;
int item = random.Next();
items.Add(item);
}
StateHasChanged();
}
string errorText = "Error!!";
protected override async Task OnInitializedAsync()
{
SelectFieldItems.Add(new SelectItem<string>() { DisplayedText = "Item 1", Value = "select item value 1", Enabled = true });
SelectFieldItems.Add(new SelectItem<string>() { DisplayedText = "Item 2", Value = "select item value 2", Enabled = true });
SelectFieldItems.Add(new SelectItem<string>() { DisplayedText = "Item 3", Value = "select item value 3", Enabled = true });
SelectFieldItems.Add(new SelectItem<string>() { DisplayedText = "Item 4", Value = "select item value 4", Enabled = true });
SelectFieldItems.Add(new SelectItem<string>() { DisplayedText = "Item 5", Value = "select item value 5", Enabled = false });
SelectFieldItems.Add(new SelectItem<string>() { DisplayedText = "Item 6", Value = "select item value 6", Enabled = true });
SelectFieldItems.Add(new SelectItem<string>() { DisplayedText = "Item 7", Value = "select item value 7", Enabled = true });
SelectFieldItems.Add(new SelectItem<string>() { DisplayedText = "Item 8", Value = "select item value 8", Enabled = false });
SelectFieldItems.Add(new SelectItem<string>() { DisplayedText = "Item 9", Value = "select item value 9", Enabled = true });
SelectFieldItems.Add(new SelectItem<string>() { DisplayedText = "Item 10", Value = "select item value 10", Enabled = true });
SelectedItemValue = SelectFieldItems[0].Value;
FillItemsList();
}
}

@ -48,13 +48,11 @@ public partial class TextInput: InputBase
private async Task ChangeValueAsync(ChangeEventArgs args)
{
await ValueChanged.InvokeAsync(args.Value.ToString());
StateHasChanged();
}
private async Task Clear()
{
await ValueChanged.InvokeAsync(string.Empty);
StateHasChanged();
}

@ -1,9 +0,0 @@
namespace Connected.Models
{
public class SelectItem<ValueType>
{
public string DisplayedText { get; set; }
public ValueType Value { get; set; }
public bool Enabled { get; set; }
}
}
Loading…
Cancel
Save