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

Fixed the hide password hint which is showing when the entry is focused #25768

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

devanathan-vaithiyanathan
Copy link
Contributor

@devanathan-vaithiyanathan devanathan-vaithiyanathan commented Nov 11, 2024

Root cause

  • Setting entry.IsPassword for a password field simply maps to setting textField.SecureTextEntry in the underlying macOS native control.
  • However, on macOS, setting SecureTextEntry alone triggers the system to display a password hint popup whenever the field gains focus. This behavior is native in macOS and isn’t explicitly managed or customized within MAUI.

Description of Change

  • To prevent the appearance of password hints in .NET MAUI on macOS and iOS, we set textField.TextContentType = UITextContentType.OneTimeCode.
  • This property avoids triggering password autofill suggestions or security prompts that are typically displayed when SecureTextEntry is enabled. By specifying OneTimeCode, we effectively restrict the macOS system from showing password hints.
    It prioritizes the detection of one-time codes, which can affect the display of password hints. This is because the system recognizes the field as intended for a one-time code rather than a password, and thus, it doesn’t show password suggestions.

Issues Fixed

Fixes #17105

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Output Screenshots

Before After
17105_macOS_BeforeChanges.mov
17105_macOs_AfterChanges.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Nov 11, 2024
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@@ -32,6 +32,8 @@ public static void UpdateIsPassword(this UITextField textField, IEntry entry)
}
else
textField.SecureTextEntry = entry.IsPassword;

textField.TextContentType = UITextContentType.OneTimeCode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could include an UITest verifying the behavior after merge #25710

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will follow this PR, and once it’s merged, I’ll write a UI test case to verify the behavior.

@@ -32,6 +32,8 @@ public static void UpdateIsPassword(this UITextField textField, IEntry entry)
}
else
textField.SecureTextEntry = entry.IsPassword;

textField.TextContentType = UITextContentType.OneTimeCode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use a compilation directive to only apply this change on Catalyst?

Also, It is outside the scope of PR, but it would be interesting to create a Catalyst specific Platform Specific allowing to set the https://developer.apple.com/documentation/swiftui/view/textcontenttype(_:)-ufdv (password, emailAddress etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since TextFieldExtensions.cs is already platform-specific to iOS, I have confirmed that the mentioned issue is reproducible on both iOS and Mac Catalyst. Therefore, this change will not impact other platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-entry Entry community ✨ Community Contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to hide the password hint which is showing when the entry is focused
2 participants