Skip to content

Commit

Permalink
fixes #491 [HxSearchBox] Discrepancy in placeholder implementation wi…
Browse files Browse the repository at this point in the history
…th floating labels
  • Loading branch information
hakenr committed Jan 8, 2024
1 parent 4e25e6e commit 0bcac2b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ protected override void OnParametersSet()
throw new InvalidOperationException($"Cannot use {nameof(IInputWithPlaceholder.Placeholder)} with floating labels.");
}
}

/// <summary>
/// When there is no EditContext cascading parameter, let's create a new one and assign it to the CascadedEditContext private property in the base InputBase class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@onblur="HandleInputBlur"
inputmode="search"
enabled="@Enabled"
placeholder="@Placeholder"
placeholder="@(LabelType == LabelType.Floating ? "placeholder" : Placeholder)"
class="@CssClassHelper.Combine(
"form-control",
(!HasInputGroupEnd && HasInputGroups ? "hx-search-box-input-with-search-icon" : null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ public HxSearchBox()
dotnetObjectReference = DotNetObjectReference.Create(this);
}

/// <inheritdoc />
protected override void OnParametersSet()
{
if ((LabelType == LabelType.Floating) && !String.IsNullOrEmpty(Placeholder))
{
throw new InvalidOperationException($"Cannot use {nameof(Placeholder)} with floating labels.");
}
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5470,6 +5470,9 @@
Indicates whether the <see cref="P:Havit.Blazor.Components.Web.Bootstrap.HxSearchBox`1.TextQuery"/> has been below minimum required length recently (before data provider loading is completed).
</summary>
</member>
<member name="M:Havit.Blazor.Components.Web.Bootstrap.HxSearchBox`1.OnParametersSet">
<inheritdoc />
</member>
<member name="F:Havit.Blazor.Components.Web.Bootstrap.HxSearchBox`1.InputKeyboardNavigationIndex">
<summary>
Input's index for the keyboard navigation. If this is the current index, then no item is selected.
Expand Down

0 comments on commit 0bcac2b

Please sign in to comment.