Skip to content

Commit f6587ce

Browse files
authored
PasswordField Fix AdornmentIcon Not Showing (#192)
1 parent fdfd46b commit f6587ce

File tree

3 files changed

+57
-40
lines changed

3 files changed

+57
-40
lines changed

CodeBeam.MudBlazor.Extensions/Components/PasswordField/MudPasswordField.razor

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,50 @@
1919
ForId="@FieldId">
2020
<InputContent>
2121
<CascadingValue Name="Standalone" Value="false" IsFixed="true">
22-
<MudInputExtended T="string"
23-
@ref="InputReference"
24-
@attributes="UserAttributes"
25-
InputType="@_passwordInput"
26-
Lines="@Lines"
27-
Style="@Style"
28-
Variant="@Variant"
29-
TextUpdateSuppression="@TextUpdateSuppression"
30-
Value="@Text"
31-
ValueChanged="(s) => SetTextAsync(s)"
32-
Placeholder="@Placeholder"
33-
Disabled=@Disabled
34-
DisableUnderLine="@DisableUnderLine"
35-
ReadOnly="@ReadOnly"
36-
MaxLength="@MaxLength"
37-
Adornment="MudBlazor.Adornment.End"
38-
AdornmentIcon="@_passwordIcon"
39-
AdornmentColor="@AdornmentColor"
40-
AdornmentAriaLabel="@AdornmentAriaLabel"
41-
IconSize="@IconSize"
42-
OnAdornmentClick="AdornmentClick"
43-
Error="@Error"
44-
ErrorId="@ErrorId"
45-
Immediate="@Immediate"
46-
Margin="@Margin"
47-
OnBlur="@OnBlurredAsync"
48-
OnKeyDown="@InvokeKeyDown"
49-
OnInternalInputChanged="OnChange"
50-
OnKeyPress="@InvokeKeyPress"
51-
OnKeyUp="@InvokeKeyUp"
52-
KeyDownPreventDefault="KeyDownPreventDefault"
53-
KeyPressPreventDefault="KeyPressPreventDefault"
54-
KeyUpPreventDefault="KeyUpPreventDefault"
55-
HideSpinButtons="true"
56-
Clearable="@Clearable"
57-
OnClearButtonClick="@OnClearButtonClick"
58-
Pattern="@Pattern"/>
22+
<MudInputExtended T="string"
23+
@ref="InputReference"
24+
@attributes="UserAttributes"
25+
InputType="@_passwordInput"
26+
Lines="@Lines"
27+
Style="@Style"
28+
Variant="@Variant"
29+
TextUpdateSuppression="@TextUpdateSuppression"
30+
Value="@Text"
31+
ValueChanged="(s) => SetTextAsync(s)"
32+
Placeholder="@Placeholder"
33+
Disabled=@Disabled
34+
DisableUnderLine="@DisableUnderLine"
35+
ReadOnly="@ReadOnly"
36+
MaxLength="@MaxLength"
37+
AdornmentAriaLabel="@AdornmentAriaLabel"
38+
Error="@Error"
39+
ErrorId="@ErrorId"
40+
Immediate="@Immediate"
41+
Margin="@Margin"
42+
OnBlur="@OnBlurredAsync"
43+
OnKeyDown="@InvokeKeyDown"
44+
OnInternalInputChanged="OnChange"
45+
OnKeyPress="@InvokeKeyPress"
46+
OnKeyUp="@InvokeKeyUp"
47+
KeyDownPreventDefault="KeyDownPreventDefault"
48+
KeyPressPreventDefault="KeyPressPreventDefault"
49+
KeyUpPreventDefault="KeyUpPreventDefault"
50+
HideSpinButtons="true"
51+
Clearable="@Clearable"
52+
OnClearButtonClick="@OnClearButtonClick"
53+
Pattern="@Pattern">
54+
<AdornmentEnd>
55+
@if (CustomAdornment != null)
56+
{
57+
@CustomAdornment
58+
}
59+
else
60+
{
61+
<MudIconButton Icon="@_passwordIcon" Color="@AdornmentColor" Size="@IconSize" OnClick="AdornmentClick"></MudIconButton>
62+
}
63+
</AdornmentEnd>
64+
65+
</MudInputExtended>
5966
</CascadingValue>
6067
</InputContent>
6168
</MudInputControl>

CodeBeam.MudBlazor.Extensions/Components/PasswordField/MudPasswordField.razor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public partial class MudPasswordField<T> : MudDebouncedInput<T>
4444
/// </summary>
4545
[Parameter] public EventCallback<MouseEventArgs> OnClearButtonClick { get; set; }
4646

47+
/// <summary>
48+
/// RenderFragment for end adornment.
49+
/// </summary>
50+
[Parameter] public RenderFragment CustomAdornment { get; set; }
51+
4752
public override ValueTask FocusAsync()
4853
{
4954
return InputReference.FocusAsync();
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<MudGrid>
2-
<MudItem Class="d-flex gap-4 align-center flex-wrap">
3-
<MudPasswordField @bind-Value="@_password" @bind-PasswordMode="@_passwordMode" Variant="Variant.Outlined" />
4-
<MudSwitch @bind-Checked="_passwordMode" Color="Color.Primary">Password Mode</MudSwitch>
2+
<MudItem xs="12" sm="8" Class="d-flex align-center">
3+
<MudPasswordField @bind-Value="@_password" @bind-PasswordMode="@_passwordMode" Variant="Variant.Outlined" IconSize="_size" />
4+
</MudItem>
5+
6+
<MudItem xs="12" sm="4">
7+
<MudSwitchM3 @bind-Checked="_passwordMode" Color="Color.Secondary">Password Mode</MudSwitchM3>
8+
<MudSelectExtended @bind-Value="_size" ItemCollection="Enum.GetValues<Size>()" Label="Icon Size" Variant="Variant.Outlined" />
59
</MudItem>
610
</MudGrid>
711

812
@code{
913
string _password = "asdf";
1014
bool _passwordMode;
15+
Size _size = Size.Medium;
1116
}

0 commit comments

Comments
 (0)