Skip to content

Opening a Dialog from the ActionSheet doesn't work without timeout or callback #2115

Closed
@Keithcat767

Description

@Keithcat767

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

  1. Have an ActionSheet component and a Dialog inside the same component
  2. Have an option inside the ActionSheet with an onPress function that toggles the open state of the Dialog
  3. Note that the dialog will not open
  4. 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

Metadata

Metadata

Assignees

Labels

buga bug in one of the components

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions