Telegram-Mini-Apps / telegram-apps

Made from scratch TypeScript packages, examples and documentation you will surely need to start developing on Telegram Mini Apps.
https://docs.telegram-mini-apps.com/
MIT License
702 stars 197 forks source link

[Bug]: Opening the popup closes the Mini App on macOS #481

Closed paulonev closed 1 month ago

paulonev commented 1 month ago

Telegram Application

Telegram for macOS

Describe the Bug

The Mini App instance is closed after popup is shown, even though the popup.open(...).then() is not calling the close() method to manually close the window.

The issue persists in Telegram client 11.1.267602 running on macOS v14.5.

If you feel the need to analyze the code, please clone the repo I prepared for the demonstration purposes (currently I don't have an opportunity to prepare the sandbox).

There's this line of code in there:

const onCloseClicked = () => {
      if (Object.entries(form.formState.dirtyFields).length === 0) {
          form.reset();
          setOpen(false);
          return;
      }

      popup.open({ message: "Data will be removed", buttons: [
          { id: "cancel", type: "cancel" },
          { id: "ok", type: "destructive", text: "ok" }
      ]}).then((id) => {
          if (id === "ok") {
              setOpen(false);
              form.reset();
          }
      });
  }

the setOpen(false) is responsible for closing the modal only, not the Mini App window

To Reproduce

Steps to reproduce the behavior:

  1. Launch the demo mini app - https://t.me/twademopopup_bot
  2. Click on "Toggle" to preview the modal, it contains the form with 2 inputs: text and select
  3. Enter data in the fields and attempt to close the modal by clicking arrow button in the top left corner.
  4. The confirmation popup is shown, but the Mini App window got closed

image

Expected Behavior

The confirmation popup is shown and the Mini App is still open

paulonev commented 1 month ago

After recent update for macOS users 11.2.2.268402 the issue has gone. I'm closing the issue

paulonev commented 1 month ago

After recent update for macOS users 11.2.2.268402 the issue has gone. I'm closing the issue