Skip to content

Commit d2a714d

Browse files
committed
Revert "Dialog - RN63 broke Modal's onDismiss method, this fixes our API (#1026)"
This reverts commit 7ee9fc1.
1 parent 317cac8 commit d2a714d

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

generatedTypes/components/dialog/OverlayFadingBackground.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ interface Props {
44
dialogVisibility?: boolean;
55
modalVisibility?: boolean;
66
overlayBackgroundColor?: string;
7-
onFadeDone?: () => void;
87
}
98
declare const OverlayFadingBackground: {
10-
({ testID, dialogVisibility, modalVisibility, overlayBackgroundColor, onFadeDone }: Props): JSX.Element;
9+
({ testID, dialogVisibility, modalVisibility, overlayBackgroundColor }: Props): JSX.Element;
1110
displayName: string;
1211
};
1312
export default OverlayFadingBackground;

src/components/dialog/OverlayFadingBackground.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ interface Props {
77
dialogVisibility?: boolean;
88
modalVisibility?: boolean;
99
overlayBackgroundColor?: string;
10-
onFadeDone?: () => void;
1110
}
1211

1312
const OverlayFadingBackground = ({
1413
testID,
1514
dialogVisibility,
1615
modalVisibility,
17-
overlayBackgroundColor,
18-
onFadeDone
16+
overlayBackgroundColor
1917
}: Props) => {
2018
const fadeAnimation = useRef(new Animated.Value(0)).current;
2119

@@ -24,8 +22,8 @@ const OverlayFadingBackground = ({
2422
toValue,
2523
duration: 400,
2624
useNativeDriver: true
27-
}).start(onFadeDone);
28-
}, [fadeAnimation, onFadeDone]);
25+
}).start();
26+
}, [fadeAnimation]);
2927

3028
useEffect(() => {
3129
if (!dialogVisibility) {

src/components/dialog/index.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,6 @@ class Dialog extends Component<DialogProps, DialogState> {
161161
}
162162
}
163163

164-
// TODO: revert adding this workaround once RN fixes https://github.com/facebook/react-native/issues/29455
165-
onFadeDone = () => {
166-
if (!this.state.modalVisibility) {
167-
setTimeout(() => { // unfortunately this is needed if a modal needs to open on iOS
168-
_.invoke(this.props, 'onDialogDismissed', this.props);
169-
_.invoke(this.props, 'onModalDismissed', this.props);
170-
}, 50);
171-
}
172-
}
173-
174164
onDismiss = () => {
175165
this.setState({modalVisibility: false}, () => {
176166
const props = this.props;
@@ -231,7 +221,6 @@ class Dialog extends Component<DialogProps, DialogState> {
231221
const {useSafeArea, bottom, overlayBackgroundColor, testID} = this.props;
232222
const addBottomSafeArea = Constants.isIphoneX && (useSafeArea && bottom);
233223
const bottomInsets = Constants.getSafeAreaInsets().bottom - 8; // TODO: should this be here or in the input style?
234-
const onFadeDone = Constants.isIOS ? this.onFadeDone : undefined;
235224

236225
return (
237226
<View
@@ -244,7 +233,6 @@ class Dialog extends Component<DialogProps, DialogState> {
244233
modalVisibility={modalVisibility}
245234
dialogVisibility={dialogVisibility}
246235
overlayBackgroundColor={overlayBackgroundColor}
247-
onFadeDone={onFadeDone}
248236
/>
249237
{this.renderDialogView()}
250238
{addBottomSafeArea && <View style={{marginTop: bottomInsets}}/>}
@@ -265,7 +253,7 @@ class Dialog extends Component<DialogProps, DialogState> {
265253
animationType={'none'}
266254
onBackgroundPress={this.hideDialogView}
267255
onRequestClose={this.hideDialogView}
268-
// onDismiss={this.onModalDismissed}
256+
onDismiss={this.onModalDismissed}
269257
supportedOrientations={supportedOrientations}
270258
accessibilityLabel={accessibilityLabel}
271259
>

0 commit comments

Comments
 (0)