Closed
Description
Description
If you try to open a Dialog from an option in an ActionSheet, it doesn't seem to wait until after the ActionSheet is fully dismissed and therefore is prevented from being opened. I can confirm it works if I use setTimeout to wait long enough to open my dialog or if I use the onModalDismissed prop to attempt to open the dialog.
Related to
- Components
- Demo
- Docs
- Typings
Steps to reproduce
- Have an ActionSheet component and a Dialog inside the same component
- Have an option inside the ActionSheet with an onPress function that toggles the open state of the Dialog
- Note that the dialog will not open
- Add a setTimeout of 500ms and see that it will now properly open
Expected behavior
The dialog will open after the ActionSheet has fully dismissed.
Actual behavior
The dialog doesn't display unless you explicitly tell it to wait for the animation to finish
More Info
Code snippet
export default function MyDemoScreen() {
const [showEditModal, setShowEditModal] = useState(false);
const [showActions, setShowActions] = useState(false);
return (
<>
<Dialog
useSafeArea
visible={showEditModal}
onDismiss={() => setShowEditModal(false)}
>
<View>
<Text>TEST</Text>
</View>
</Dialog>
<ActionSheet
title={`Edit`}
message={"Message goes here"}
options={[
{
label: "Rename",
onPress: () => {
setShowEditModal(true);
},
},
{ label: "Cancel" },
]}
visible={showActions}
onDismiss={() => setShowActions(false)}
/>
</>
);
}
Screenshots/Video
Environment
- React Native: 0.64.3
- React Native UI Lib: 6.18.0
Affected platforms
- Android
- iOS
- Web