-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Make Modal's onDismiss work on Fabric.
#42601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Differential Revision: D52959996
2425376 to
bc7a7af
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Differential Revision: D52959996
bc7a7af to
e86038c
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Base commit: b8778ab |
e86038c to
5dee28b
Compare
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Differential Revision: D52959996
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
| if (Platform.OS === 'ios') { | ||
| this.setState({isRendering: false}, () => { | ||
| if (this.props.onDismiss) { | ||
| this.props.onDismiss(); | ||
| } | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Wouldn't it be better from an OOT platform standpoint to use early return? If we would check Platform.OS === 'android' and return. Then no changes would be needed for macOS to support it.
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Differential Revision: D52959996
5dee28b to
c7f3b0c
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Differential Revision: D52959996
c7f3b0c to
aae1891
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Differential Revision: D52959996
aae1891 to
9e849ca
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Differential Revision: D52959996
9e849ca to
1a45258
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Differential Revision: D52959996
1a45258 to
14e8da9
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Differential Revision: D52959996
befed28 to
cbaeffb
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Reviewed By: sammy-SC Differential Revision: D52959996
cbaeffb to
7b20f9d
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Reviewed By: sammy-SC Differential Revision: D52959996
7b20f9d to
cc01266
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Reviewed By: sammy-SC Differential Revision: D52959996
cc01266 to
bdb85f3
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Reviewed By: sammy-SC Differential Revision: D52959996
bdb85f3 to
4ec1a95
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Reviewed By: sammy-SC Differential Revision: D52959996
4ec1a95 to
ba96111
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Reviewed By: sammy-SC Differential Revision: D52959996
ba96111 to
44a45f9
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
Summary: After S390064, the OnDismiss event for Modal from D52445670 was reverted. The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything. The most important thing for our short term goal is to make the `OnDismiss` work only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless). We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs. ## The Problem: The reason why the onDismiss event does not work is because, as soon as the `visible` property is turned to `false`, the component is removed by the React tree. When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired. ## The Solution: We made this work by "delaying" when the component need to be removed from the reacat Tree. Rather then rendering or node or not based on the `visible` props, we are introducing a `State` object that keeps track when the Modal is rendered or not. The `state.isRendering` property is set to `true` when the `visible` prop is set to `true`. For iOS, when `visible` prop is set to `false`, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set the `state.isRendering` property to false and the Modal can be considered dismissed. Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented. ## Changelog: [iOS][Fixed] - `onDismiss` now work on iOS with Fabric, in both Bridge and Bridgeless mode. Reviewed By: sammy-SC Differential Revision: D52959996
44a45f9 to
7369719
Compare
|
This pull request was exported from Phabricator. Differential Revision: D52959996 |
|
This pull request has been merged in c7a0dff. |
Summary:
After S390064, the OnDismiss event for Modal from D52445670 was reverted.
The diff was too big and caused the SEV, so we are trying to reimplement it gradually to make sure we don't brake anything.
The most important thing for our short term goal is to make the
OnDismisswork only for iOS (following the official docs, Android never supported it) for Fabric (Bridge and Bridgeless).We also want to minimize the changes t the JS infrastructure, so we are trying not to alter the JS APIs.
The Problem:
The reason why the onDismiss event does not work is because, as soon as the
visibleproperty is turned tofalse, the component is removed by the React tree.When this happens, Fabric deallocate the ShadowNode and the EventEmitter. Therefore, the event is not fired.
The Solution:
We made this work by "delaying" when the component need to be removed from the reacat Tree.
Rather then rendering or node or not based on the
visibleprops, we are introducing aStateobject that keeps track when the Modal is rendered or not.The
state.isRenderingproperty is set totruewhen thevisibleprop is set totrue.For iOS, when
visibleprop is set tofalse, instead, we wait for the Native side to actually dismiss the View and to invoke the event. When the event is fired, we manually set thestate.isRenderingproperty to false and the Modal can be considered dismissed.Notice that this makes also useless to have the Modal Native's snapshot to simulate that the modal is still presented.
Changelog:
[iOS][Fixed] -
onDismissnow work on iOS with Fabric, in both Bridge and Bridgeless mode.Differential Revision: D52959996