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

Added UpdateOnInput to MatInputText to allow @bind:event="oninput". #574

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
49 changes: 49 additions & 0 deletions src/MatBlazor.Demo/Demo/DemoMatTextField.razor
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,55 @@
bool? boolNullValue;
}

")></BlazorFiddle>
</SourceContent>
</DemoContainer>


<h5 class="mat-h5">Bind Event</h5>

<DemoContainer>
<Content>


<p>
<MatStringField @bind-Value="@MyString11" Label="Update on Change"></MatStringField>
Value: @MyString11
</p>

<p>
<MatStringField @bind-Value="@MyString12" UpdateOnInput="true" Label="Update On Input"></MatStringField>
Value: @MyString12
</p>

@code
{
public string MyString11 { get; set; }
public string MyString12 {get;set;}
}

</Content>
<SourceContent>
<BlazorFiddle Template="MatBlazor" Code=@(@"


<p>
<MatStringField @bind-Value=""@MyString11"" Label=""Update on Change""></MatStringField>
Value: @MyString11
</p>

<p>
<MatStringField @bind-Value=""@MyString12"" UpdateOnInput=""true"" Label=""Update On Input""></MatStringField>
Value: @MyString12
</p>

@code
{

public string MyString11 {get;set;}
public string MyString12 {get;set;}
}

")></BlazorFiddle>
</SourceContent>
</DemoContainer>
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ protected virtual bool InputTextReadOnly()
[Parameter]
public string Type { get; set; } = "text";

[Parameter]
public bool UpdateOnInput { get; set; }

protected string BindEvent => UpdateOnInput ? "oninput" : "onchange";


protected virtual EventCallback<KeyboardEventArgs> OnKeyDownEvent()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

@if (TextArea)
{
<textarea style="@InputStyle" @ref="InputRef" placeholder="@PlaceHolder" required=@Required class="@InputClassMapper.AsString()" id="@Id" @bind="@CurrentValueAsString" aria-label="@Label" oninput="@OnInput" @onkeydown="@OnKeyDownEvent()" onkeyup=@OnKeyUp onfocusout="@OnFocusOutEvent.Value" onkeypress="@OnKeyPress" onfocus="@OnFocusEvent.Value" disabled=@Disabled readonly="@InputTextReadOnly()" @attributes="Attributes" />
<textarea style="@InputStyle" @ref="InputRef" placeholder="@PlaceHolder" required=@Required class="@InputClassMapper.AsString()" id="@Id" @bind="@CurrentValueAsString" @bind:event="@BindEvent" aria-label="@Label" oninput="@OnInput" @onkeydown="@OnKeyDownEvent()" onkeyup=@OnKeyUp onfocusout="@OnFocusOutEvent.Value" onkeypress="@OnKeyPress" onfocus="@OnFocusEvent.Value" disabled=@Disabled readonly="@InputTextReadOnly()" @attributes="Attributes" />
}
else
{
<input style="@InputStyle" @ref="InputRef" type="@Type" placeholder="@PlaceHolder" required=@Required class="@InputClassMapper.AsString()" id="@Id" @bind="@CurrentValueAsString" aria-label="@Label" oninput="@OnInput" @onkeydown="@OnKeyDownEvent()" onkeyup=@OnKeyUp [email protected] onkeypress="@OnKeyPress" onfocus="@OnFocusEvent.Value" disabled=@Disabled readonly="@InputTextReadOnly()" @attributes="Attributes"/>
<input style="@InputStyle" @ref="InputRef" type="@Type" placeholder="@PlaceHolder" required=@Required class="@InputClassMapper.AsString()" id="@Id" @bind="@CurrentValueAsString" @bind:event="@BindEvent" aria-label="@Label" oninput="@OnInput" @onkeydown="@OnKeyDownEvent()" onkeyup=@OnKeyUp [email protected] onkeypress="@OnKeyPress" onfocus="@OnFocusEvent.Value" disabled=@Disabled readonly="@InputTextReadOnly()" @attributes="Attributes"/>
}


Expand Down