-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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] Implement the onPressIn property for the fabric implementation of TextInput #14480
base: main
Are you sure you want to change the base?
Conversation
This is great! Can we also add an e2etest to make this change more stable in the future? Instructions here: https://github.com/microsoft/react-native-windows/wiki/E2E-Testing-(Fabric) It also looks like rntester already has a TextInput you can refer too! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think more than TextInput
will require an onPressIn
event and parts of this needs to be implemented up in HostPlatformViewEventEmitter
rather than directly here.
For reference WindowsTextInputEventEmitter
inherits from ViewEventEmitter
which inherits from HostPlatformViewEventEmitter
which inherits from BaseViewEventEmitter
. HostPlatformViewEventEmitter
is where we implement eventcode that multiple components will need.
@@ -66,5 +66,12 @@ void WindowsTextInputEventEmitter::onContentSizeChange(OnContentSizeChange event | |||
return textInputMetricsContentSizePayload(runtime, event); | |||
}); | |||
} | |||
void WindowsTextInputEventEmitter::onPressIn(OnPressIn event) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default version of this function should be implemented in HostPlatformViewEventEmitter
and should dispatch to "pressIn".
Then, you should override that function here in WindowsTextInputEventEmitter
to instead dispatch the event to "textInputPressIn".
See other comments for details.
@@ -41,11 +41,16 @@ class WindowsTextInputEventEmitter : public ViewEventEmitter { | |||
facebook::react::Size contentSize; | |||
}; | |||
|
|||
struct OnPressIn { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struct should instead be something like PressEvent
and put it up in the HostPlatformViewEventEmitter
for re-use elsewhere.
See https://reactnative.dev/docs/pressevent for the other fields the event should have in JS - I'm not sure if some (all?) of these need to be implemented in native code (some may be added in JS). You might need to update your test to display the event and verify what's present.
See other comments for details.
void onChange(OnChange value) const; | ||
void onSelectionChange(const OnSelectionChange &value) const; | ||
void onSubmitEditing(OnSubmitEditing value) const; | ||
void onKeyPress(OnKeyPress value) const; | ||
void onContentSizeChange(OnContentSizeChange value) const; | ||
void onPressIn(OnPressIn value) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be implemented as a virtual fucntion in HostPlatformViewEventEmitter
for re-use elsewhere.
See other comments for details.
@@ -659,6 +659,14 @@ void WindowsTextInputComponentView::OnPointerPressed( | |||
auto hr = m_textServices->TxSendMessage(msg, static_cast<WPARAM>(wParam), static_cast<LPARAM>(lParam), &lresult); | |||
args.Handled(hr != S_FALSE); | |||
} | |||
|
|||
// Implements OnPressIn event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably okay here for now, but it might need to be moved up into a more common place too, like in ComponentView.h
@HariniMalothu17 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Description
Type of Change
Why
Implement the onPressIn property for the fabric implementation of TextInput.
This property was available in RNW Paper via TextInputViewManager
See https://reactnative.dev/docs/textinput#onpressin for details.
Resolves #13127
What
Implemented the onPressIn property for the fabric implementation of TextInput.
Screenshots
Recording.2025-04-04.025511.mp4
Testing
Tested using playground-composition App,
Added an alert prompt to the onPressIn event when the TextInput is pressed.
Changelog
Yes
Added a brief summary of onPressIn to use in the release notes for the next release.
Microsoft Reviewers: Open in CodeFlow