Skip to content

Commit 398c17c

Browse files
committed
Add support for immediate changes to RadzenTextBox (enabled via Immediate=true). Closes #909.
1 parent 49adc95 commit 398c17c

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Radzen.Blazor/RadzenTextBox.razor

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
@inherits FormComponentWithAutoComplete<string>
22
@if (Visible)
33
{
4+
@if (Immediate)
5+
{
6+
<input @ref="@Element" id="@GetId()" disabled="@Disabled" readonly="@ReadOnly" name="@Name" style="@Style" @attributes="Attributes" class="@GetCssClass()" tabindex="@(Disabled ? "-1" : $"{TabIndex}")"
7+
placeholder="@CurrentPlaceholder" maxlength="@MaxLength" autocomplete="@AutoCompleteAttribute" aria-autocomplete="@AriaAutoCompleteAttribute" value="@Value" @oninput="@OnChange" />
8+
}
9+
else
10+
{
411
<input @ref="@Element" id="@GetId()" disabled="@Disabled" readonly="@ReadOnly" name="@Name" style="@Style" @attributes="Attributes" class="@GetCssClass()" tabindex="@(Disabled ? "-1" : $"{TabIndex}")"
512
placeholder="@CurrentPlaceholder" maxlength="@MaxLength" autocomplete="@AutoCompleteAttribute" aria-autocomplete="@AriaAutoCompleteAttribute" value="@Value" @onchange="@OnChange" />
13+
}
614
}

Radzen.Blazor/RadzenTextBox.razor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ public partial class RadzenTextBox : FormComponentWithAutoComplete<string>
3636
public bool Trim { get; set; }
3737

3838
/// <summary>
39-
/// Handles change event of the built-in <c>input</c> elementt.
39+
/// Gets or sets a value indicating whether the component should update the value immediately when the user types. Set to <c>false</c> by default.
40+
/// </summary>
41+
[Parameter]
42+
public bool Immediate { get; set; }
43+
44+
/// <summary>
45+
/// Handles change event of the built-in <c>input</c> element.
4046
/// </summary>
4147
protected async Task OnChange(ChangeEventArgs args)
4248
{

RadzenBlazorDemos/Pages/TextBoxConfig.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<RadzenColumn Size="12" SizeMD="4">
2121
<RadzenCard>
2222
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Change on every input</RadzenText>
23-
<RadzenTextBox @oninput=@(args => OnChange(args.Value.ToString(), "TextBox with change on every input")) Style="width: 100%" aria-label="TextBox with change on every input" />
23+
<RadzenTextBox Immediate="true" Change=@(value => OnChange(value, "TextBox with change on every input")) Style="width: 100%" aria-label="TextBox with change on every input" />
2424
</RadzenCard>
2525
</RadzenColumn>
2626
<RadzenColumn Size="12" SizeMD="4">

0 commit comments

Comments
 (0)