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

NavigationRail is not shown in a parent without fixed height #303

Closed
FeodorFitsner opened this issue Sep 9, 2022 · 0 comments
Closed

NavigationRail is not shown in a parent without fixed height #303

FeodorFitsner opened this issue Sep 9, 2022 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@FeodorFitsner
Copy link
Contributor

FeodorFitsner commented Sep 9, 2022

Internally NavigationRail is made of Column with Expand inside it.
It fails to render if put into a parent control without a fixed height.

Solutions:

  1. Add expand=True to NavigationRail or set its height to a fixed value.
  2. Put NavigationRail inside a control with expand=True or a fixed height.

The following code fails:

import flet
from flet import *
from flet import icons


def main(page: Page):
    page.add(
        Row(
            [
                NavigationRail(
                    selected_index=0,
                    label_type="all",
                    min_width=100,
                    min_extended_width=400,
                    leading=FloatingActionButton(icon=icons.CREATE, text="Add"),
                    group_alignment=-0.9,
                    destinations=[
                        NavigationRailDestination(
                            icon=icons.FAVORITE_BORDER,
                            selected_icon=icons.FAVORITE,
                            label="First",
                        ),
                        NavigationRailDestination(
                            icon_content=Icon(icons.BOOKMARK_BORDER),
                            selected_icon_content=Icon(icons.BOOKMARK),
                            label="Second",
                        ),
                        NavigationRailDestination(
                            icon=icons.SETTINGS_OUTLINED,
                            selected_icon_content=Icon(icons.SETTINGS),
                            label_content=Text("Settings"),
                        ),
                    ],
                    on_change=lambda e: print(
                        "Selected destination:", e.control.selected_index
                    ),
                )
            ],
        )
    )

flet.app(target=main)

The fix:

Add expand=True to Row control.

@FeodorFitsner FeodorFitsner added the bug Something isn't working label Sep 9, 2022
@FeodorFitsner FeodorFitsner added this to the Controls-S2 milestone Sep 20, 2022
@FeodorFitsner FeodorFitsner changed the title Display an error when parent is not expanded NavigationRail is not shown in a parent without fixed height Oct 5, 2022
@FeodorFitsner FeodorFitsner added the status: working on it Working on a fix for the issue label Oct 8, 2022
@FeodorFitsner FeodorFitsner removed the status: working on it Working on a fix for the issue label Oct 11, 2022
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

1 participant