Bug: Blazor Hybrid Password field visibility toggle

Monty 0 Reputation points
2024-11-27T09:46:55.5233333+00:00

When using the standard password field in a Blazor Hybrid web app, there is a problem with the eye icon which is used to toggle password visibility. It is functional up until the point that the user clicks off the password field. From then on the eye icon will never reappear - and therefore the user can never toggle the visibility of their password - until the user fully deletes all characters and retypes a single character. This effectively resets the password field's logic and the field operates as expected once again.

This issue is reproduced every time in the Blazor Hybrid Windows Machine hot reload preview accessed in Visual Studio 2022 Community.

As it will be confusing to some users who momentarily clicked off before resuming typing their password, is there a way to fix this behaviour?

Code:

<div class="form-group">

    <label for="pwd">Password:</label>

    <input type="password" class="form-control" id="pwd" @bind="Password" @onkeypress="HandleKeyPress"/>

</div>
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,620 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,540 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,715 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 28,786 Reputation points
    2024-11-27T10:30:15.8166667+00:00

    The password reveal button is a browser feature.

    According to the official documentation if script modifies the password field then the browser removes the password reveal button. We cannot see what the onkeypress handles does but perhaps removing the handler will restore the browser's reveal button functionality.

    https://learn.microsoft.com/en-us/microsoft-edge/web-platform/password-reveal

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.