Skip to content

bug: Cannot disable tab buttons in flet 0.80.* / 0.81.0 #6220

@xkjq

Description

@xkjq

Duplicate Check

Describe the bug

Disabling a TabBar Tab in flet 0.81.0 does not work as expected.

Code sample

Code
import flet as ft

def main(page: ft.Page):
    page.title = "Flet Tabs disable test"

    # Create tabs
    test1 = ft.Tab(label="Test 1")
    test2 = ft.Tab(label="Test 2")
    test3 = ft.Tab(label="Test 3")

    tab_bar = ft.TabBar(tabs=[test1, test2, test3])
    tab_view = ft.TabBarView(
        controls=[
            ft.Column(controls=[ft.Text("Test 1 content")]),
            ft.Column(controls=[ft.Text("Test 2 content")]),
            ft.Column(controls=[ft.Text("Test 3 content")]),
        ],
        expand=True,
    )

    tabs_control = ft.Tabs(
        selected_index=0,
        length=3,
        expand=True,
        content=ft.Column(controls=[tab_bar, tab_view], expand=True),
    )

    def disable_direct(e):
        # direct reference to the Tab object
        test2.disabled = True
        page.update()

    def enable_direct(e):
        test2.disabled = False
        page.update()

    def relabel_direct(e):
        test3.label = "Test 3 (Relabeled)"
        page.update()

    def disable_lookup(e):
        # find the TabBar from tabs_control.content.controls[0]
        tb = tabs_control.content.controls[0]
        for t in getattr(tb, "tabs", []):
            if getattr(t, "label", None) == "Test 2":
                t.disabled = True
                break
        page.update()

    def enable_lookup(e):
        tb = tabs_control.content.controls[0]
        for t in getattr(tb, "tabs", []):
            if getattr(t, "label", None) == "Test 2":
                t.disabled = False
                break
        page.update()

    # Buttons to exercise both approaches
    btns = ft.Row(
        controls=[
            ft.Button("Disable (direct)", on_click=disable_direct),
            ft.Button("Enable (direct)", on_click=enable_direct),
            ft.Button("Disable (lookup)", on_click=disable_lookup),
            ft.Button("Enable (lookup)", on_click=enable_lookup),
            ft.Button("Relabel (direct)", on_click=relabel_direct),
        ]
    )

    page.add(ft.Column(controls=[tabs_control, btns], expand=True))


if __name__ == "__main__":
    ft.run(main)

To reproduce

  1. Run the repo code
  2. Click the buttons at the bottom of the page

Expected behavior

  • Expected behavior: tab bar button is disabled and enabled via buttons
  • Actual behavior: tab bar button remains enabled

Screenshots / Videos

Captures

[Upload media here]

Operating System

Linux

Operating system details

Ubuntu 25.10

Flet version

Flet 0.81.0

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Logs

Additional details

Similar code was working in the 0.28.x version

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions