-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[0.61][iOS 13] pageSheet/formSheet dismissal from swipe not propagated #26892
Comments
Also experiencing this. |
Same here. |
Having this problem as well. |
same problem on iOS 13 |
any update on this? I was just about to use it when noticed the swipe down problem. |
Also experiencing. So frustrating. |
I had to change the presentationStyle to 'overFullScreen' to prevent swiping down. It's certainly no replacement for pageSheet, but if you need an onDismiss function to trigger it can be a temporary solution until this is fixed. |
I am using However when I do that, no function is fired. onDismiss only fires when I close it from a button. The modal won't open again if I do like this because it doesn't change it's state. |
I've been running into this issue. I wrote a library (basically just copied over React Native's Modal code) to see if I could fix this issue. I hook into the I'm not that familiar with Objective-C so I'm not sure if this is a great solution, but hopefully it helps someone. If someone more familiar thinks this is a valid solution, then I'll create a PR. |
I am also experiencing this. Please release a fix for this. |
Same. Does anyone knows how to prevent the swipe? Not a solution but a possible workaround for now |
Same issue here. Because of that it's |
Summary: # Disclaimer: I might be missing something as the solution I implemented here seems like something that was considered by original author. If this solution isn't good, I have a plan B. # Problem: `onDismiss` prop isn't being called once the modal is dismissed, this diff fixes it. Also I've noticed that `onDismiss` is meant to only work on iOS, why is that? By landing this diff, it'll be called on Android as well so we need to change the docs (https://facebook.github.io/react-native/docs/modal.html#ondismiss). ## Video that shows the problem Following code is in playground.js P70222409 which just increments number everytime onDismiss is called {F166303269} Reviewed By: shergin Differential Revision: D16109536 fbshipit-source-id: 3fba56f5671912387b217f03b613dffd89614c9d
Same problem with dismissing modal in presentation style. When I swipe it down to close, then state is not changed. |
Here is a (not-ideal/hacky!) workaround while awaiting a proper fix if anyone is also desperate for the pull-down modal behaviour. It does not solve the problem that there's no way to fire a callback when user dismisses the modal, but enables reopening the modal after being pulled-down. The idea behind the logic is to check if an imperative modal-open is being attempted on an "already open" modal, and forcing a couple of re-renders to reset the value on the modal. import { useState, useEffect } from 'react';
export const useModalState = initialState => {
const [modalVisible, setModalVisible] = useState(initialState);
const [forceModalVisible, setForceModalVisible] = useState(false);
const setModal = modalState => {
// tyring to open "already open" modal
if (modalState && modalVisible) {
setForceModalVisible(true);
}
setModalVisible(modalState);
};
useEffect(() => {
if (forceModalVisible && modalVisible) {
setModalVisible(false);
}
if (forceModalVisible && !modalVisible) {
setForceModalVisible(false);
setModalVisible(true);
}
}, [forceModalVisible, modalVisible]);
return [modalVisible, setModal];
};
// use it the same way as before (as docs recommend)
const [modalVisible, setModalVisible] = useModalState(false) Hope it may help some of you! |
I wasn't able to get the workaround @lrholmes posted above to work. For whatever reason, the TouchableOpacity used to open the modal (and interestingly any adjacent TouchOpacity components) would no longer fire their onPress after the modal was swiped down. Desperate to get this working, I ended up putting a ScrollView around the entire modal content and used onDragEnd to flip the modal state variable. Works if your modal contents don't scroll. Not by any means ideal but was a reasonable trade-off in my situation. |
Just try use Modal component inside TouchableWithoutFeedback.
It was help me |
Patch workaround for React Native 0.61.2 Download patch Installation
|
Same issue - even with the patched versions. |
@martsie You need to recompile your app. Set a breakpoints in the newly added lines to verify |
Sorry, @martsie there was a line missing from my diff. You'll need to say that you're implementing a delegate as well ( |
@r4mdat just put your Modal in a View with
|
This worked perfectly fine for me. I would suggest this over any other options as it takes the least amount of code and is the most understandable. Also, once the issue is fixed, it will be the simplest to revert. |
Summary: Starting on iOS 13, a View Controller presented modally will have a "bottom sheet" style unless it's explicitly presented full screen. Before this, modals on iOS were only being dismissed programatically by setting `visible={false}`. However, now that the dismissal can happen on the OS side, we need a callback to be able to update the state. This PR reuses the `onRequestClose` prop already available for tvOS and Android, and makes it work on iOS for this use case. Should fix #26892 ## Changelog [iOS] [Added] - Add support for onRequestClose prop to Modal on iOS 13+ Pull Request resolved: #27618 Test Plan: I tested this using the RNTester app with the Modal example: 1. Select any presentation style other than the full screen ones 2. Tap Present and the modal is presented 3. Swipe down on the presented modal until dismissed 4. Tap Present again and a second modal should be presented ![Screen Recording 2019-12-26 at 14 05 33](https://user-images.githubusercontent.com/8739/71477208-0ac88c80-27e9-11ea-9342-8631426a9b80.gif) Differential Revision: D19235758 Pulled By: shergin fbshipit-source-id: c0f1d946c77ce8d1baab209eaef7eb64697851df
Hey everyone, Im having the same issue. onDismiss property doesn't clear the Modal component (swipe down iOS). Can someone help me? Thanks |
Hey, If you embed this to your project you just have to set the onRequestClose property and the swipe down works as expected for |
@ps73 It’s a little hard for me to judge if this is generic enough that it would be a solution for all. If you do think or want to let others weigh in, mind creating a PR for it? |
Show man! |
@vasiliicuhar solution worked for me with RN 0.62.2:
|
@alloy update on this bug? Not working yet in 0.63.4. |
I alas have no updates on this, my last question was if somebody wanted to solve it. |
That's embarrassing. Nobody could fix this Modal problem in React Native for long time. |
I've tried quite a few of the above, nothing works for me ... others are quite ugly to implement. Any advice on how to work around this issue ... seems quite weird. |
@edi I've updated my patch-file for 0.63.4. Just follow my instructions in the first comment. After that you have to reinstall your app on your simulator or real device. After all these steps you can use |
So there is a fix for this issue? Why not include this in a new release? |
Airbnb was right. React Native really s*cks. After every version change, even so basic functionalities stop working for no reason and it's really tiring to track these things. And it seems Facebook or repository admins do NOT want to fix/merge the most of these issues. I'm switching to Flutter. |
Have people tried in 0.64? |
Not working in |
:) No surprise. |
Yeah, there must be a good reason (I assume it's performance) why the patch was included and then removed from the recent version. As a temporary workaround, you can use React Native Modalize, I think they pretty much have everything you want to work with page/form sheet modals (inc. swipe down to close). |
My solution works only who uses Create a modal stack in your navigator and nest a regular stack inside it. Then simply call your modal screen anywhere in your project, just like your other screens. Now, you can have ModalPresentationIOS transition in both platform. When you cannot pass the navigation prop into the component directly, you can use
|
@rewieer can this be reopened? This is still an issue. |
I just encountered this too. I was pretty surprised @thomasttvo's suggestion fixed it. Would you mind explaining how the fix works?
<View style={{ height: 0 }}>
<Modal ...>
<YourModalContent />
</Modal>
<View> |
@fallaciousreasoning the height=0 trick doesn't seem to work for me :/ |
That was a long time ago, but I vaguely remember it has something to do with event propagation and TouchableWithoutFeedback, not entirely sure tho. |
Modal is very base functionality. And it should stay as native. It doesn't make sense to use a third party dependency or library to be able to solve this basic problem or to be able to use modal. |
Thanks @vasiliicuhar <Modal
visible={showModal}
animationType="slide"
presentationStyle="formSheet"
>
<TouchableWithoutFeedback
// for bug which prevents dismiss from firing on swipe close
// https://github.com/facebook/react-native/issues/26892
onPressOut={() => console.log('Close modal')}
>
<View style={{ flex: 1 }}>
{/* YOUR CONTENT */}
</View>
</TouchableWithoutFeedback>
</Modal> |
I can confirm too, this example finally works with 0.63 & 0.64. I hope they will not break again this base functionality. |
This solution close modal on any touch outside, not on swipe. We are waiting for merge this pr: #31500 |
I agree it's not ideal but only working solution so far. I hope they merge this because I think FB hates iOS and they love to keep it broken. |
Still having this issue |
I am still having issues with this. Waiting on #31500 |
When the user dismisses the modal by a swipe gesture using a custom presentation style,
the event isn't caught by onDismiss.
React Native version: 0.61.0
Sample code :
I'm no expert in iOS, but this article might give a hint.
I can fill in a PR with some help.
The text was updated successfully, but these errors were encountered: