How to use the @shopify/app-bridge/actions.Modal.Action function in @shopify/app-bridge

To help you get started, we’ve selected a few @shopify/app-bridge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shopify / polaris-react / src / components / Modal / Modal.tsx View on Github external
if (isIframeModal(transformedProps)) {
        (this.appBridgeModal as AppBridgeModal.ModalIframe).set(
          transformedProps,
        );
      } else {
        (this.appBridgeModal as AppBridgeModal.ModalMessage).set(
          transformedProps,
        );
      }
    }

    if (wasOpen !== open) {
      if (open) {
        this.appBridgeModal.dispatch(AppBridgeModal.Action.OPEN);
      } else {
        this.appBridgeModal.dispatch(AppBridgeModal.Action.CLOSE);
      }
    }

    if (!wasOpen && open) {
      this.focusReturnPointNode = document.activeElement as HTMLElement;
    } else if (
      wasOpen &&
      !open &&
      this.focusReturnPointNode != null &&
      document.contains(this.focusReturnPointNode)
    ) {
      this.focusReturnPointNode.focus();
      this.focusReturnPointNode = null as any;
    }
  }