Skip to content

Commit d44af5a

Browse files
tom-unrnbot
andauthored
Fix onFocus/onBlur event bubbling in 0.60 stable (facebook#509)
* Fix onFocus/onBlur event bubbling (facebook#506) * Update scripts to publish react-native-macos-init * Clean up merge markers * Restored ios:macos RNTester parity except for InputAccessoryView. * Revert "Restored ios:macos RNTester parity except for InputAccessoryView." This reverts commit 5a67ae0. * Remove unnecessary android builds and tar file upload. * Fix onFocus/onBlur View events to properly bubble. * The Text component can also be selectable={true} and needs the same focus/blur event triggering as View. Co-authored-by: React-Native Bot <53619745+rnbot@users.noreply.github.com> * Added new RCTFocusChangeEvent to static xcodeproj's * Change vmImage to ubuntu-latest for Android builds. Co-authored-by: React-Native Bot <53619745+rnbot@users.noreply.github.com>
1 parent 20b896e commit d44af5a

20 files changed

Lines changed: 272 additions & 35 deletions

.ado/android-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- job: AndroidRNPR
1313
displayName: Android React Native PR
1414
pool:
15-
vmImage: ubuntu-18.04
15+
vmImage: ubuntu-latest
1616
timeoutInMinutes: 90 # how long to run the job before automatically cancelling
1717
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
1818
steps:

.ado/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- job: RNGithubOfficePublish
6767
displayName: React-Native GitHub Publish to Office
6868
pool:
69-
vmImage: ubuntu-18.04
69+
vmImage: ubuntu-latest
7070
timeoutInMinutes: 90 # how long to run the job before automatically cancelling
7171
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
7272
steps:

.ado/setup_droid_deps.sh

100644100755
File mode changed.

Libraries/Components/Button.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const View = require('./View/View');
2121
const invariant = require('invariant');
2222

2323
import type {PressEvent} from '../Types/CoreEventTypes';
24+
import type {FocusEvent, BlurEvent} from './TextInput/TextInput'; // TODO(OSS Candidate ISS#2710739)
2425

2526
type ButtonProps = $ReadOnly<{|
2627
/**
@@ -100,6 +101,18 @@ type ButtonProps = $ReadOnly<{|
100101
* Used to locate this view in end-to-end tests.
101102
*/
102103
testID?: ?string,
104+
105+
// [TODO(OSS Candidate ISS#2710739)
106+
/**
107+
* Handler to be called when the button receives key focus
108+
*/
109+
onBlur?: ?(e: BlurEvent) => void,
110+
111+
/**
112+
* Handler to be called when the button loses key focus
113+
*/
114+
onFocus?: ?(e: FocusEvent) => void,
115+
// ]TODO(OSS Candidate ISS#2710739)
103116
|}>;
104117

105118
/**
@@ -147,6 +160,8 @@ class Button extends React.Component<ButtonProps> {
147160
nextFocusUp,
148161
disabled,
149162
testID,
163+
onFocus, // TODO(OSS Candidate ISS#2710739)
164+
onBlur, // TODO(OSS Candidate ISS#2710739)
150165
} = this.props;
151166
const buttonStyles = [styles.button];
152167
const textStyles = [styles.text];
@@ -189,6 +204,8 @@ class Button extends React.Component<ButtonProps> {
189204
testID={testID}
190205
disabled={disabled}
191206
onPress={onPress}
207+
onFocus={onFocus} // TODO(OSS Candidate ISS#2710739)
208+
onBlur={onBlur} // TODO(OSS Candidate ISS#2710739)
192209
touchSoundDisabled={touchSoundDisabled}>
193210
<View style={buttonStyles}>
194211
<Text style={textStyles} disabled={disabled}>

Libraries/Components/TextInput/TextInput.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,8 @@ const TextInput = createReactClass({
11431143
<TouchableWithoutFeedback
11441144
onLayout={props.onLayout}
11451145
onPress={this._onPress}
1146+
onFocus={this._onFocus} // TODO(macOS ISS#2323203)
1147+
onBlur={this._onBlur} // TODO(macOS ISS#2323203)
11461148
rejectResponderTermination={true}
11471149
accessible={props.accessible}
11481150
accessibilityLabel={props.accessibilityLabel}
@@ -1196,6 +1198,8 @@ const TextInput = createReactClass({
11961198
<TouchableWithoutFeedback
11971199
onLayout={props.onLayout}
11981200
onPress={this._onPress}
1201+
onFocus={this._onFocus} // TODO(macOS ISS#2323203)
1202+
onBlur={this._onBlur} // TODO(macOS ISS#2323203)
11991203
rejectResponderTermination={props.rejectResponderTermination}
12001204
accessible={props.accessible}
12011205
accessibilityLabel={props.accessibilityLabel}
@@ -1254,6 +1258,8 @@ const TextInput = createReactClass({
12541258
<TouchableWithoutFeedback
12551259
onLayout={props.onLayout}
12561260
onPress={this._onPress}
1261+
onFocus={this._onFocus} // TODO(macOS ISS#2323203)
1262+
onBlur={this._onBlur} // TODO(macOS ISS#2323203)
12571263
accessible={this.props.accessible}
12581264
accessibilityLabel={this.props.accessibilityLabel}
12591265
accessibilityRole={this.props.accessibilityRole}

Libraries/Components/Touchable/TouchableBounce.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ const TouchableBounce = ((createReactClass({
219219
onDragEnter={this.props.onDragEnter}
220220
onDragLeave={this.props.onDragLeave}
221221
onDrop={this.props.onDrop}
222+
onFocus={this.props.onFocus}
223+
onBlur={this.props.onBlur}
222224
draggedTypes={this.props.draggedTypes} // ]TODO(macOS ISS#2323203)
223225
>
224226
{this.props.children}

Libraries/Components/Touchable/TouchableHighlight.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ const TouchableHighlight = ((createReactClass({
452452
onDragEnter={this.props.onDragEnter}
453453
onDragLeave={this.props.onDragLeave}
454454
onDrop={this.props.onDrop}
455+
onFocus={this.props.onFocus}
456+
onBlur={this.props.onBlur}
455457
draggedTypes={this.props.draggedTypes} // ]TODO(macOS/win ISS#2323203)
456458
nativeID={this.props.nativeID}
457459
testID={this.props.testID}>

Libraries/Components/Touchable/TouchableOpacity.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ const TouchableOpacity = ((createReactClass({
353353
onDragEnter={this.props.onDragEnter}
354354
onDragLeave={this.props.onDragLeave}
355355
onDrop={this.props.onDrop}
356+
onFocus={this.props.onFocus}
357+
onBlur={this.props.onBlur}
356358
draggedTypes={this.props.draggedTypes} // ]TODO(macOS ISS#2323203)
357359
/* $FlowFixMe(>=0.89.0 site=react_native_fb) This comment suppresses an
358360
* error found when Flow v0.89 was deployed. To see the error, delete

Libraries/Components/Touchable/TouchableWithoutFeedback.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,12 @@ const TouchableWithoutFeedback = ((createReactClass({
340340
tooltip: this.props.tooltip, // TODO(macOS/win ISS#2323203)
341341
onClick: this.touchableHandlePress, // TODO(android ISS)
342342
onMouseEnter: this.props.onMouseEnter, // [TODO(macOS ISS#2323203)
343-
onMouseLeave: this.props.onMouseLeave, // [TODO(macOS ISS#2323203)
344-
onDragEnter: this.props.onDragEnter, // [TODO(macOS ISS#2323203)
345-
onDragLeave: this.props.onDragLeave, // [TODO(macOS ISS#2323203)
346-
onDrop: this.props.onDrop, // [TODO(macOS ISS#2323203)
343+
onMouseLeave: this.props.onMouseLeave,
344+
onDragEnter: this.props.onDragEnter,
345+
onDragLeave: this.props.onDragLeave,
346+
onDrop: this.props.onDrop,
347+
onFocus: this.props.onFocus,
348+
onBlur: this.props.onBlur,
347349
draggedTypes: this.props.draggedTypes, // ]TODO(macOS ISS#2323203)
348350
children,
349351
});

Libraries/Text/Text/RCTTextView.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
*/
77

88
#import <React/RCTComponent.h>
9+
#import <React/RCTEventDispatcher.h> // TODO(OSS Candidate ISS#2710739)
910

1011
#import <React/RCTUIKit.h> // TODO(macOS ISS#2323203)
1112

1213
NS_ASSUME_NONNULL_BEGIN
1314

1415
@interface RCTTextView : RCTUIView // TODO(macOS ISS#3536887)
1516

17+
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher; // TODO(OSS Candidate ISS#2710739)
18+
1619
@property (nonatomic, assign) BOOL selectable;
1720

1821
- (void)setTextStorage:(NSTextStorage *)textStorage

0 commit comments

Comments
 (0)