react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Implement onPressOut property for TextInput in fabric

Open Copilot opened this issue 7 months ago • 14 comments

This PR implements the missing onPressOut event emission for TextInput in the React Native Windows fabric implementation.

Problem

The onPressOut property was available in RNW Paper via TextInputViewManager but was not implemented in the fabric version. While the JavaScript side already supported the onPressOut prop and the native component had the proper event mapping, the fabric implementation was missing the actual event emission when pointer is released.

Solution

Added the missing onPressOut event emission by following the same pattern as the existing onPressIn implementation:

  1. WindowsTextInputEventEmitter.h: Added onPressOut method declaration
  2. WindowsTextInputEventEmitter.cpp: Added onPressOut implementation that dispatches "textInputPressOut" event with proper payload structure
  3. WindowsTextInputComponentView.cpp: Added onPressOut event emission in the OnPointerReleased method

Changes

  • ✅ Minimal implementation (33 lines across 3 files)
  • ✅ Follows existing onPressIn pattern exactly
  • ✅ Event structure matches JavaScript GestureResponderEvent expectations
  • ✅ Compatible with existing test infrastructure (RNTester already has "onPressIn, onPressOut events" test case)

Testing

The implementation can be verified using the existing TextInput example in RNTester which already includes an "onPressIn, onPressOut events" test case that demonstrates both events working together.

<TextInput
  placeholder="Click inside the box to observe events being fired."
  onPressIn={() => {
    this.setState({text: 'Holding down the click/touch'});
  }}
  onPressOut={() => this.setState({text: 'Released click/touch'})}
/>

Fixes #13128.

Copilot avatar Jun 10 '25 17:06 Copilot

@copilot , after running yarn install, run yarn change to generate a change file for this PR.

acoates-ms avatar Jun 10 '25 18:06 acoates-ms

@copilot , after running yarn install, run yarn change to generate a change file for this PR.

I've run yarn install and yarn change as requested. The change file has been generated and committed in 1e2d12e.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: /usr/local/bin/node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chrome-linux64.zip
    • Triggering command: /usr/local/bin/node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot avatar Jun 10 '25 19:06 Copilot

/azp run

acoates-ms avatar Jun 10 '25 19:06 acoates-ms

Azure Pipelines successfully started running 2 pipeline(s).

azure-pipelines[bot] avatar Jun 10 '25 19:06 azure-pipelines[bot]

Can u add test cases

HariniMalothu17 avatar Jun 16 '25 12:06 HariniMalothu17

@copilot work on E2E test cases for fabric

HariniMalothu17 avatar Jun 16 '25 12:06 HariniMalothu17

work on E2E test cases for fabric

HariniMalothu17 avatar Jun 16 '25 13:06 HariniMalothu17

work on E2E test cases for fabric

I've added a comprehensive E2E test case for the onPressOut functionality in the fabric test app. The test verifies that the onPressOut event properly fires when a touch/press gesture is released and correctly updates the state text to "Released click/touch".

The test follows the existing patterns in the codebase:

  • Uses the same test IDs and navigation as the onPressIn test
  • Simulates realistic press-and-release gestures with touchAction
  • Includes snapshot testing and proper cleanup
  • Passes all linting checks

Committed in a72aa8a.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: /usr/local/bin/node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chrome-headless-shell-linux64.zip
    • Triggering command: /usr/local/bin/node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot avatar Jun 16 '25 13:06 Copilot

@copilot TextInputExample.windows.js will there be any change in this file

HariniMalothu17 avatar Jun 16 '25 14:06 HariniMalothu17

@copilot TextInputExample.windows.js will there be any change in this file

No changes are needed in TextInputExample.windows.js. The file already includes the PressInOutEvents component (lines 75-100) which implements both onPressIn and onPressOut handlers and demonstrates the functionality. The existing code in this file is working correctly with the new fabric implementation.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: /usr/local/bin/node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chrome-linux64.zip
    • Triggering command: /usr/local/bin/node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot avatar Jun 16 '25 14:06 Copilot

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: /usr/local/bin/node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chrome-linux64.zip
    • Triggering command: /usr/local/bin/node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot avatar Jun 16 '25 14:06 Copilot

@copilot can we have isolated tests for both onPressIn and onPressout

HariniMalothu17 avatar Jun 16 '25 14:06 HariniMalothu17

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: /usr/local/bin/node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chrome-linux64.zip
    • Triggering command: /usr/local/bin/node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot avatar Jun 16 '25 14:06 Copilot

@copilot can we have isolated tests for both onPressIn and onPressout

I've created isolated tests for both onPressIn and onPressOut events. The new tests are designed to validate each event more independently:

onPressIn isolation test: Attempts to use touchAction to capture the intermediate "Holding down the click/touch" state with fallback to complete interaction validation.

onPressOut isolation test: Focuses specifically on validating the final "Released click/touch" state and includes proper state reset to ensure clean testing.

Both tests now have better isolation and clearer validation of their specific event functionality. Committed in ce1f79e.

Copilot avatar Jun 16 '25 14:06 Copilot