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

TextInput caret becomes visible on non-focused TextInputs on resize #14091

Merged
merged 2 commits into from
Nov 7, 2024
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": "TextInput caret becomes visible on non-focused TextInputs on resize",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {

//@cmember Show the caret
BOOL TxShowCaret(BOOL fShow) override {
// Only show the caret if we have focus
if (fShow && !m_outer->m_hasFocus) {
return false;
}
m_outer->ShowCaret(m_outer->windowsTextInputProps().caretHidden ? false : fShow);
return true;
}
Expand Down Expand Up @@ -909,6 +913,7 @@ void WindowsTextInputComponentView::UnmountChildComponentView(

void WindowsTextInputComponentView::onLostFocus(
const winrt::Microsoft::ReactNative::Composition::Input::RoutedEventArgs &args) noexcept {
m_hasFocus = false;
Super::onLostFocus(args);
if (m_textServices) {
LRESULT lresult;
Expand All @@ -920,6 +925,7 @@ void WindowsTextInputComponentView::onLostFocus(

void WindowsTextInputComponentView::onGotFocus(
const winrt::Microsoft::ReactNative::Composition::Input::RoutedEventArgs &args) noexcept {
m_hasFocus = true;
Super::onGotFocus(args);
if (m_textServices) {
LRESULT lresult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct WindowsTextInputComponentView
int m_cDrawBlock{0};
bool m_needsRedraw{false};
bool m_drawing{false};
bool m_hasFocus{false};
bool m_clearTextOnSubmit{false};
bool m_multiline{false};
DWORD m_propBitsMask{0};
Expand Down
Loading