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

Bug: Two Datepicker Opening Issue #2025

Closed
perna-python opened this issue Nov 3, 2023 · 2 comments
Closed

Bug: Two Datepicker Opening Issue #2025

perna-python opened this issue Nov 3, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@perna-python
Copy link

Description

I have encountered a issue in my web application. In a specific view, I have added a datepicker component, and when I try to open it, two datepickers appear on the screen. The first datepicker closes when I press OK or Cancel and then the second one appears and works as it should

Code example to reproduce the issue:

import datetime
import flet as ft

def main(page: ft.Page):
    page.title = "Example DatePicker"
    
    def change_date(e):
        print(f"Date picker changed, value is {date_picker.value}")

    def date_picker_dismissed(e):
        print(f"Date picker dismissed, value is {date_picker.value}")

    date_picker = ft.DatePicker(
        on_change=change_date,
        on_dismiss=date_picker_dismissed,
        first_date=datetime.datetime(2023, 10, 1),
        last_date=datetime.datetime(2024, 10, 1),
    )

    page.overlay.append(date_picker)

    date_button = ft.ElevatedButton(
        "Pick date",
        icon=ft.icons.CALENDAR_MONTH,
        on_click=lambda _: date_picker.pick_date(),
    )

    def route_change(route):
        page.views.clear()
        page.views.append(
            ft.View(
                "/",
                [
                    ft.AppBar(title=ft.Text("Flet app"), bgcolor=ft.colors.SURFACE_VARIANT),
                    ft.ElevatedButton("Visit DatePicker", on_click=lambda _: page.go("/datePicker")),
                ],
            )
        )
        if page.route == "/datePicker":
            page.views.append(
                ft.View(
                    "/datePicker",
                    [
                        ft.AppBar(title=ft.Text("Date Picker"), bgcolor=ft.colors.SURFACE_VARIANT),
                        date_button,
                    ],
                )
            )
        page.update()

    def view_pop(view):
        page.views.pop()
        top_view = page.views[-1]
        page.go(top_view.route)

    page.on_route_change = route_change
    page.on_view_pop = view_pop
    page.go(page.route)


ft.app(target=main)



Describe the results you received:

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Flet version (pip show flet):

Name: flet
Version: 0.11.0
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page:
Author: Appveyor Systems Inc.
Author-email: [email protected]
License: Apache-2.0
Location: c:\users\pstef\appdata\local\programs\python\python310\lib\site-packages
Requires: copier, flet-runtime, packaging, qrcode, watchdog, websocket-client, websockets
Required-by:

Operating system:

Windows

Additional environment details:

@FeodorFitsner FeodorFitsner added the bug Something isn't working label Nov 3, 2023
@FeodorFitsner
Copy link
Contributor

Looking into this. Good issue! I'm able to reproduce it with AlertDialog as well 🥹

@ndonkoHenri
Copy link
Contributor

Similar: #2011

FeodorFitsner added a commit that referenced this issue Nov 6, 2023
zrr1999 pushed a commit to zrr1999/flet that referenced this issue Jul 17, 2024
* AlertDialog uses global state

* DatePicker uses global state

* State on the control level

* Control-level state

Fix flet-dev#2025, Fix flet-dev#1807, Fix flet-dev#1236, Fix flet-dev#1772

* Fix control tests

* Bump fl_chart to 0.64.0

* Fix `scroll_to` with 0 animation duration

Fix flet-dev#1659

* Fix page.width/.height on session start

Fix flet-dev#1960

* Fix Flet version retrieval on non-English environments

Fix flet-dev#1997
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants