AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.48k stars 2.21k forks source link

Double-clicks in `TextBox` with `PasswordChar` should select all text, not individual words #14956

Closed nil4 closed 7 months ago

nil4 commented 7 months ago

Describe the bug

In a TextBox with PasswordChar set, double-clicking currently selects individual 'words' from the underlying Text.

This is a helpful behavior for regular text boxes, and when a password is revealed. For cloaked password input, however, selecting the entire text on double-click would arguably be more useful and consistent with desktop OS native controls.

To Reproduce

git clone https://github.com/AvaloniaUI/ControlCatalogStandalone.git
cd ControlCatalogStandalone/ControlCatalogStandalone.Desktop
dotnet run

Select TextBox from the left-hand side menu, and type a few individual words in the input field labeled Password Box.

In the repro below, the text entered is 123 456. Double-clicking any of the * characters displayed selects the closest 'word' in the underlying value:

PasswordCharSelection

Expected behavior

Double-clicking in a TextBox with a PasswordChar set should select all text, not just individual words.

Doing so would match native OS controls behavior (tested on Windows, Linux and MacOS). It might arguably also help users paste or overtype to replace the entire password value, instead of doing so piecewise.

Avalonia version

11.0.10, 11.0.999-cibuild

OS

Windows, macOS, Linux

Additional context

No response

timunie commented 7 months ago

@nil4 if you want, a PR is welcome.

rabbitism commented 7 months ago

What 'native OS control' are your testing for Windows?

nil4 commented 7 months ago

The password inputs under Control Panel > User Accounts > Credential Manager and the built-in RDP client mstsc authentication dialog are a couple of examples.

rabbitism commented 7 months ago

@nil4 Thank you! never notice this feature, I think it's important to avoid potential password pattern leakage.