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
693 stars 192 forks source link

[Bug]: backButton doesn't call callback on clicking #501

Closed JinNguyen96 closed 1 month ago

JinNguyen96 commented 1 month ago

Telegram Application

Telegram for iOS, Telegram for macOS

Describe the Bug

I'm using @telegram-apps/sdk 2.4.0 for developing mini app with Nextjs 14. After mounting backButton and set callback for onClick event, tapping on the button does trigger the event but the callback isn't called

Devices tested:

Iphone 15pro - BUG Macbook M3 Pro - BUG

To Reproduce

Steps to reproduce the behavior:

  1. set up code like this

    ...
    import {  backButton  } from "@telegram-apps/sdk"
    ...
    useEffect(() => {
    backButton.mount()
    const offClick = backButton.onClick(() => console.log('clicked'))
    
    return () => {
    offClick()
    }
    }, [])
  2. Click back button on mini app
  3. back_button_pressed event is triggered: [Telegram.WebView] < receiveEvent back_button_pressed null without clicked text

Expected Behavior

callback should be called and log clicked once the back button is clicked

heyqbnk commented 1 month ago

If you see this output:

[Telegram.WebView] < receiveEvent back_button_pressed null

It means, you are using the Telegram SDK also. Remove the telegram-web-app.js file, as it is not compatible with @telegram-apps/sdk