Skip to content

Commit 3146c9c

Browse files
authored
fix: remove view config mismatches (#2642)
1 parent 39abcfb commit 3146c9c

File tree

8 files changed

+32
-22
lines changed

8 files changed

+32
-22
lines changed

packages/react-native/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
2020
uiViewClassName: 'RCTScrollContentView',
2121
bubblingEventTypes: {},
2222
directEventTypes: {},
23-
validAttributes: {},
23+
// [macOS
24+
validAttributes: {
25+
inverted: true,
26+
},
27+
// macOS]
2428
};
2529

2630
const ScrollContentViewNativeComponent: HostComponent<Props> =

packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
114114
topScrollToTop: {
115115
registrationName: 'onScrollToTop',
116116
},
117+
// [macOS
118+
...(Platform.OS === 'macos' && {
119+
topPreferredScrollerStyleDidChange: {
120+
registrationName: 'onPreferredScrollerStyleDidChange',
121+
},
122+
topInvertedDidChange: {
123+
registrationName: 'onInvertedDidChange',
124+
},
125+
}),
126+
// macOS]
117127
},
118128
validAttributes: {
119129
alwaysBounceHorizontal: true,

packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ const RCTTextInputViewConfig = {
9292
registrationName: 'onKeyPressSync',
9393
},
9494
// [macOS
95+
topPaste: {
96+
registrationName: 'onPaste',
97+
},
9598
topAutoCorrectChange: {
9699
registrationName: 'onAutoCorrectChange',
97100
},
@@ -182,6 +185,7 @@ const RCTTextInputViewConfig = {
182185
onChangeSync: true,
183186
onKeyPressSync: true,
184187
// [macOS
188+
onSubmitEditing: true,
185189
onPaste: true,
186190
onAutoCorrectChange: true,
187191
onSpellCheckChange: true,

packages/react-native/Libraries/Components/TextInput/TextInputState.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function focusTextInput(textField: ?HostInstance) {
106106
// [macOS currentlyFocusedInputRef does not account for the fact that any arbritrary view can
107107
// recieve focus on desktop. https://github.com/facebook/react-native/pull/52472/ fixes this,
108108
// disable the check for now
109-
// currentlyFocusedInputRef !== textField &&
109+
(Platform.OS === 'macos' || currentlyFocusedInputRef !== textField) &&
110110
// macOS]
111111
// $FlowFixMe - `currentProps` is missing in `NativeMethods`
112112
textField.currentProps?.editable !== false;

packages/react-native/React/Base/RCTUIKit.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,6 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
447447
@property (nonatomic, copy) RCTDirectEventBlock onDragLeave;
448448
@property (nonatomic, copy) RCTDirectEventBlock onDrop;
449449

450-
// Focus events
451-
@property (nonatomic, copy) RCTBubblingEventBlock onBlur;
452-
@property (nonatomic, copy) RCTBubblingEventBlock onFocus;
453-
454450
@property (nonatomic, copy) RCTBubblingEventBlock onResponderGrant;
455451
@property (nonatomic, copy) RCTBubblingEventBlock onResponderMove;
456452
@property (nonatomic, copy) RCTBubblingEventBlock onResponderRelease;

packages/react-native/React/Views/RCTView.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
162162
* macOS Properties
163163
*/
164164

165+
@property (nonatomic, copy) RCTBubblingEventBlock onFocus;
166+
@property (nonatomic, copy) RCTBubblingEventBlock onBlur;
167+
165168
// `allowsVibrancy` is readonly on NSView, so let's create a new property to make it assignable
166169
// that we can set through JS and the getter for `allowsVibrancy` can read in RCTView.
167170
@property (nonatomic, assign) BOOL allowsVibrancyInternal;
@@ -176,16 +179,10 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
176179
@property (nonatomic, copy) NSArray<RCTHandledKey*> *keyUpEvents;
177180

178181
// Shadow Properties
179-
@property (nonatomic, strong) NSColor *shadowColor;
182+
@property (nonatomic, assign) CGColorRef shadowColor;
180183
@property (nonatomic, assign) CGFloat shadowOpacity;
181184
@property (nonatomic, assign) CGFloat shadowRadius;
182185
@property (nonatomic, assign) CGSize shadowOffset;
183186
#endif // macOS]
184187

185-
/**
186-
* Common Focus Properties
187-
*/
188-
@property (nonatomic, copy) RCTBubblingEventBlock onFocus;
189-
@property (nonatomic, copy) RCTBubblingEventBlock onBlur;
190-
191188
@end

packages/react-native/React/Views/RCTView.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ - (NSString *)description
725725
}
726726

727727
#if TARGET_OS_OSX // [macOS
728-
- (void)setShadowColor:(NSColor *)shadowColor
728+
- (void)setShadowColor:(CGColorRef)shadowColor
729729
{
730730
if (_shadowColor != shadowColor)
731731
{
@@ -764,7 +764,8 @@ - (void)setShadowRadius:(CGFloat)shadowRadius
764764
-(void)didUpdateShadow
765765
{
766766
NSShadow *shadow = [NSShadow new];
767-
shadow.shadowColor = [[self shadowColor] colorWithAlphaComponent:[self shadowOpacity]];
767+
NSColor *baseShadowColor = [NSColor colorWithCGColor:_shadowColor];
768+
shadow.shadowColor = [baseShadowColor colorWithAlphaComponent:[self shadowOpacity]];
768769
shadow.shadowOffset = [self shadowOffset];
769770
shadow.shadowBlurRadius = [self shadowRadius];
770771
[self setShadow:shadow];

packages/react-native/React/Views/RCTViewManager.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ - (RCTShadowView *)shadowView
254254
RCT_REMAP_VIEW_PROPERTY(shadowOpacity, layer.shadowOpacity, float)
255255
RCT_REMAP_VIEW_PROPERTY(shadowRadius, layer.shadowRadius, CGFloat)
256256
#else // [macOS
257-
RCT_EXPORT_VIEW_PROPERTY(shadowColor, NSColor)
257+
RCT_EXPORT_VIEW_PROPERTY(shadowColor, CGColor)
258258
RCT_EXPORT_VIEW_PROPERTY(shadowOffset, CGSize)
259259
RCT_EXPORT_VIEW_PROPERTY(shadowOpacity, CGFloat)
260260
RCT_EXPORT_VIEW_PROPERTY(shadowRadius, CGFloat)
@@ -634,15 +634,13 @@ - (void) updateAccessibilityRole:(RCTView *)view withDefaultView:(RCTView *)defa
634634
RCT_REMAP_VIEW_PROPERTY(display, reactDisplay, YGDisplay)
635635
RCT_REMAP_VIEW_PROPERTY(zIndex, reactZIndex, NSInteger)
636636

637-
// [macOS
638-
RCT_EXPORT_VIEW_PROPERTY(onFocus, RCTBubblingEventBlock)
639-
RCT_EXPORT_VIEW_PROPERTY(onBlur, RCTBubblingEventBlock)
640-
// macOS]
641-
642-
643637
#if TARGET_OS_OSX // [macOS
638+
644639
#pragma mark - macOS properties
645640

641+
RCT_EXPORT_VIEW_PROPERTY(onFocus, RCTBubblingEventBlock)
642+
RCT_EXPORT_VIEW_PROPERTY(onBlur, RCTBubblingEventBlock)
643+
646644
RCT_EXPORT_VIEW_PROPERTY(onMouseEnter, RCTDirectEventBlock)
647645
RCT_EXPORT_VIEW_PROPERTY(onMouseLeave, RCTDirectEventBlock)
648646
RCT_EXPORT_VIEW_PROPERTY(onDragEnter, RCTDirectEventBlock)

0 commit comments

Comments
 (0)