Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When view = ft.AppView.WEB_BROWSER, the page.on_disconnect will be called when the page is refreshed. #4505

Open
1 task done
noobbei opened this issue Dec 6, 2024 · 1 comment

Comments

@noobbei
Copy link

noobbei commented Dec 6, 2024

Duplicate Check

Describe the bug

I want to perform some operations when the tab or browser is closed. So I intended to do some operations in page.on_disconnect. However, when I refresh the page, the on_disconnect function is also called, which is something I don't want to happen.

Code sample

Code
import flet as ft


def main(page: ft.Page):
    page.add(ft.Text('hello world!'))
    page.update()

    page.on_close = lambda e: print('closed!')


ft.app(target=main, view=ft.WEB_BROWSER)

To reproduce

Run example code.

Expected behavior

I hope that the on_disconnect function will only be called when the page or the browser is closed.

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

Windows 11

Flet version

0.25.1

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

@noobbei
Copy link
Author

noobbei commented Dec 6, 2024

Sorry, there is an error in the sample code. It should be page.on_disconnect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant