Skip to content

fix: resolve component-wrapped views in Page root/top view accessors#6414

Merged
FeodorFitsner merged 3 commits intorelease/v0.85.0from
fix/render-views-drawer-accessors
Apr 13, 2026
Merged

fix: resolve component-wrapped views in Page root/top view accessors#6414
FeodorFitsner merged 3 commits intorelease/v0.85.0from
fix/render-views-drawer-accessors

Conversation

@FeodorFitsner
Copy link
Copy Markdown
Contributor

@FeodorFitsner FeodorFitsner commented Apr 13, 2026

Summary

  • Fixes bug: page.show_drawer()/close_drawer() fail under page.render_views() #6413page.show_drawer() (and every page-level accessor backed by the root view) raised TypeError: object of type 'Component'/'View' has no len() under page.render_views().
  • BasePage.__root_view() / __top_view() now go through a new __resolved_views() helper that unwraps Component wrappers and normalizes a single-View return into a one-element list.
  • Adds examples/apps/declarative/navigation_drawer — declarative NavigationDrawer example covering the repro.

Test plan

  • uv run flet run sdk/python/examples/apps/declarative/navigation_drawer/main.py — tap the menu icon, drawer opens; selecting a destination updates the page title and closes the drawer.
  • Existing imperative drawer example (examples/apps/routing_navigation/drawer_navigation) still works.

Summary by Sourcery

Fix page root/top view resolution to work with component-wrapped declarative views and add a declarative navigation drawer example app.

New Features:

  • Add a declarative NavigationDrawer example app demonstrating drawer navigation driven by selected destination state.

Bug Fixes:

  • Resolve page root and top view accessors to correctly handle component-wrapped views and single-view renders when using render_views.

Enhancements:

  • Introduce a shared helper to normalize and unwrap views returned from declarative rendering before accessing root/top views.

…6413)

Under `page.render_views()`, `self.views` is a `Component` (or a single
`View` once unwrapped), not a `list[View]`. `__root_view()` / `__top_view()`
called `len(self.views)` directly, breaking `page.show_drawer()`,
`close_drawer()`, and every page-level accessor backed by the root view
(appbar, drawer, navigation_bar, controls, ...).

Add `__resolved_views()` that unwraps component wrappers and normalizes
a single-View return into a one-element list, and route both view
accessors through it.

Also adds a declarative `NavigationDrawer` example under
`examples/apps/declarative/navigation_drawer` covering the repro from
the issue.
@FeodorFitsner FeodorFitsner added this to the 0.85.0 milestone Apr 13, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 13, 2026

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: 22b7c91
Status: ✅  Deploy successful!
Preview URL: https://491d5bab.flet-examples.pages.dev
Branch Preview URL: https://fix-render-views-drawer-acce.flet-examples.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 13, 2026

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: f7e690b
Status:⚡️  Build in progress...

View logs

@FeodorFitsner FeodorFitsner merged commit 178f16a into release/v0.85.0 Apr 13, 2026
42 of 70 checks passed
@FeodorFitsner FeodorFitsner deleted the fix/render-views-drawer-accessors branch April 13, 2026 19:58
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

Successfully merging this pull request may close these issues.

bug: page.show_drawer()/close_drawer() fail under page.render_views()

1 participant