bug: child component loses click events after parent rerender when passed as a control prop
Duplicate Check
- I searched the opened issues and did not find an exact duplicate.
Describe the bug
In Flet 1.0.0, a clickable control returned by a child @ft.component can stop receiving events after it is passed as a control argument to another component that subsequently re-renders because of its own local state change.
A regular Flet control passed through the same controls argument continues working.
The minimal reproduction below shows the difference:
direct Button
→ passed to wrapper through controls
→ wrapper re-renders
→ on_click still works
child @ft.component
→ returned Container passed through the same controls argument
→ wrapper re-renders
→ on_click no longer reaches PythonThere is no exception or crash. The event is simply not delivered to the child component's handler.
Code sample
Codeimport asyncio
import flet as ft
@ft.component
def ChildClickable():
def handle_click(e):
print(">>> CHILD COMPONENT CLICK WORKS")
return ft.Container(
padding=20,
border=ft.Border.all(1.5, ft.Colors.PRIMARY),
border_radius=12,
ink=True,
on_click=handle_click,
content=ft.Text(
"Child component — click me",
weight=ft.FontWeight.BOLD,
),
)
@ft.component
def RerenderWrapper(controls: list[ft.Control]):
revealed, set_revealed = ft.use_state(False)
print(f">>> WRAPPER RENDER: revealed={revealed}")
async def reveal():
print(">>> EFFECT STARTED")
await asyncio.sleep(0.2)
print(">>> EFFECT: set_revealed(True)")
set_revealed(True)
ft.use_effect(
reveal,
dependencies=[],
cleanup=lambda: None,
)
return ft.Column(
spacing=20,
controls=[
ft.Text(
f"Wrapper state: {revealed}",
weight=ft.FontWeight.BOLD,
),
*controls,
],
)
@ft.component
def App():
def direct_click(e):
print(">>> DIRECT CONTROL CLICK WORKS")
direct_control = ft.Button(
"Direct control — click me",
on_click=direct_click,
)
child_component = ChildClickable()
return RerenderWrapper(
controls=[
direct_control,
child_component,
]
)
def main(page: ft.Page):
page.title = "Flet component prop reconciliation test"
page.padding = 30
page.render(App)
if __name__ == "__main__":
ft.run(main)To reproduce
- Run the sample with Flet
1.0.0. - Wait until the console shows:
>>> WRAPPER RENDER: revealed=False
>>> EFFECT STARTED
>>> EFFECT: set_revealed(True)
>>> WRAPPER RENDER: revealed=True- Click Direct control — click me several times.
- Click Child component — click me several times.
Expected behavior
Both controls should continue dispatching their on_click events after RerenderWrapper re-renders.
The child component should print:
>>> CHILD COMPONENT CLICK WORKSfor every click.
Actual behavior
The direct control keeps working:
>>> DIRECT CONTROL CLICK WORKS
>>> DIRECT CONTROL CLICK WORKS
>>> DIRECT CONTROL CLICK WORKSRepeated clicks on the child component produce no output at all.
The child component remains rendered and visible, but handle_click() is never called.
Operating System
Windows
Operating system details
Windows desktop (exact OS build was not captured during the minimal reproduction).
Flet version
flet==1.0.0
Python: 3.13.x
Regression
I'm not sure / I don't know.
Logs
>>> WRAPPER RENDER: revealed=False
>>> EFFECT STARTED
>>> EFFECT: set_revealed(True)
>>> WRAPPER RENDER: revealed=True
>>> DIRECT CONTROL CLICK WORKS
>>> DIRECT CONTROL CLICK WORKS
>>> DIRECT CONTROL CLICK WORKSRepeated clicks on the child component produce no additional output.
There is no Python traceback or session crash.
Additional details
The important difference appears to be how the controls reach the re-rendering component.
This works:
@ft.component
def Wrapper():
return ft.Column(
controls=[
ChildClickable(),
]
)But in the reproduction above the child component is instantiated by the outer component and then passed to the re-rendering component:
child_component = ChildClickable()
return RerenderWrapper(
controls=[
child_component,
]
)After RerenderWrapper changes its own local state and re-renders, the child component remains visible but its event handler no longer receives clicks.
A regular ft.Button passed through the same controls argument is unaffected.
This may be related to control identity / reconciliation / session-index handling.
Potentially related:
- #6826 fixed a previous case where re-rendered controls could lose event delivery because control identity and session index state were not reconciled correctly. The fix is already included in Flet
1.0.0, so this report does not assume it is the same bug. - #6854 reports
ListTile.on_click/on_long_pressnot firing in a different nested-layout scenario. The reproduction is different, so this report is not intended as a duplicate.
Source: flet-dev/flet