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

Fabric secure text entry #11484

Merged
merged 5 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Enable secureTextEntry for Fabric - Supply password character - Set TXTBIT_USEPASSWORD - Fix problem when backspacing on short strings",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
}

//@cmember Get the character to display for password input
HRESULT TxGetPasswordChar(_Out_ TCHAR *pch) override {
assert(false);
return {};
HRESULT TxGetPasswordChar(_Out_ wchar_t *pch) override {
*pch = L'\u2022';
return S_OK;
}

//@cmember Get the accelerator character
Expand Down Expand Up @@ -614,6 +614,13 @@ void WindowsTextInputComponentView::updateProps(
propBits |= TXTBIT_CHARFORMATCHANGE;
}

if (oldTextInputProps.secureTextEntry != newTextInputProps.secureTextEntry) {
propBitsMask |= TXTBIT_USEPASSWORD;
chrisglein marked this conversation as resolved.
Show resolved Hide resolved
if (newTextInputProps.secureTextEntry) {
propBits |= TXTBIT_USEPASSWORD;
}
}

if (oldTextInputProps.multiline != newTextInputProps.multiline) {
propBitsMask |= TXTBIT_MULTILINE | TXTBIT_WORDWRAP;
if (newTextInputProps.multiline) {
Expand Down Expand Up @@ -831,10 +838,10 @@ std::string WindowsTextInputComponentView::GetTextFromRichEdit() const noexcept
auto str = BstrToStdString(bstr);

// JS gets confused by the \r\0 ending
if (*(str.end() - 1) == '\0') {
if (str.size() > 0 && *(str.end() - 1) == '\0') {
str.pop_back();
}
if (*(str.end() - 1) == '\r') {
if (str.size() > 0 && *(str.end() - 1) == '\r') {
str.pop_back();
}
SysFreeString(bstr);
Expand Down