Skip to content

Commit

Permalink
Do not conditionally ignore event props (#11059)
Browse files Browse the repository at this point in the history
* Do not conditionally ignore event props

We derive BaseViewConfig from the iOS implementation, which included a
line that conditionally ignored event props in case the code was used on
any platform other than iOS. This prevented event props from reaching
native components that used `createViewConfig` (e.g., Text).

This removes the conditional function from BaseViewProps for Windows.

* Change files

* Add onMouseEnter/Leave event support to BaseViewConfig

Resolves #11060

* yarn lint:fix
  • Loading branch information
rozele committed Jan 10, 2023
1 parent 6bb0ecd commit 372107f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Do not conditionally ignore event props",
"packageName": "react-native-windows",
"email": "erozell@outlook.com",
"dependentChangeType": "patch"
}
30 changes: 24 additions & 6 deletions vnext/src/Libraries/NativeComponent/BaseViewConfig.windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import type {PartialViewConfigWithoutName} from './PlatformBaseViewConfig';

import ReactNativeStyleAttributes from '../Components/View/ReactNativeStyleAttributes';
import {
ConditionallyIgnoredEventHandlers,
DynamicallyInjectedByGestureHandler,
} from './ViewConfigIgnore';
import {DynamicallyInjectedByGestureHandler} from './ViewConfigIgnore';

const bubblingEventTypes = {
// Generic Events
Expand Down Expand Up @@ -162,6 +159,15 @@ const directEventTypes = {
onGestureHandlerStateChange: DynamicallyInjectedByGestureHandler({
registrationName: 'onGestureHandlerStateChange',
}),
// [Windows
// Mouse enter/leave events
topMouseEnter: {
registrationName: 'onMouseEnter',
},
topMouseLeave: {
registrationName: 'onMouseLeave',
},
// Windows]
};

const validAttributesForNonEventProps = {
Expand Down Expand Up @@ -307,7 +313,9 @@ const validAttributesForNonEventProps = {
};

// Props for bubbling and direct events
const validAttributesForEventProps = ConditionallyIgnoredEventHandlers({
// [Windows
const validAttributesForEventProps = {
// Windows]
onLayout: true,
onMagicTap: true,

Expand Down Expand Up @@ -346,13 +354,23 @@ const validAttributesForEventProps = ConditionallyIgnoredEventHandlers({
onPointerLeave: true,
onPointerOver: true,
onPointerOut: true,
});

// [Windows
// Mouse enter/leave events
onMouseEnter: true,
onMouseLeave: true,
// Windows]
// [Windows
};
// Windows]

/**
* On iOS, view managers define all of a component's props.
* All view managers extend RCTViewManager, and RCTViewManager declares these props.
*/
// [Windows
const PlatformBaseViewConfigWindows: PartialViewConfigWithoutName = {
// Windows]
bubblingEventTypes,
directEventTypes,
validAttributes: {
Expand Down

0 comments on commit 372107f

Please sign in to comment.