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

Tabs stop responding to events when visibility is changed #7449

Closed
1 task done
edgarGracia opened this issue Feb 16, 2024 · 2 comments · Fixed by #7470
Closed
1 task done

Tabs stop responding to events when visibility is changed #7449

edgarGracia opened this issue Feb 16, 2024 · 2 comments · Fixed by #7470
Labels
bug Something isn't working

Comments

@edgarGracia
Copy link

Describe the bug

If a gr.Tab visibility is set to False, and then to True again, the tab stops sending events to the .select event listener. Also, the last tab triggers all the other tabs' events at once.

I tried with and without the gr.Tabs() block and setting the tab id but none works.

I'm using gr.update(visible=x) to change the visibility.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

Run the following code and steps to reproduce the issue. It will create 10 tabs and a slider to select how many tabs to show. The console and a Textbox displays which tab is selected.

  1. Launch the demo and click the different tabs. You will see the Textbox and console display the selected tab.
  2. Move the slider to, for example, 5 and see the tabs disappear. Now move it back to 10 and see all the tabs again.
  3. Now if you click the tabs 0 to 4 it works well, but if you click 5 to 8, it does not.
  4. Also, look at the console and click the last tab. You will see how it triggers the events of tabs 5 to 9.
import gradio as gr

def update_visibility(slider):
    return [
        (gr.update(visible=True) if i < slider else gr.update(visible=False))
        for i in range(10)
    ]

def on_select(i):
    def fn():
        print(i)
        return i
    return fn

with gr.Blocks() as demo:
    slider = gr.Slider(
        minimum=1,
        maximum=10,
        value=10,
        step=1
    )
    text = gr.Textbox()
    
    tab_list = []
    with gr.Tabs() as tabs:
        for i in range(10):
            with gr.Tab(i) as tab:
                tab.select(on_select(i), None, text)
                tab_list.append(tab)
    
    slider.change(
        update_visibility,
        inputs=slider,
        outputs=tab_list
    )

demo.launch()

Screenshot

No response

Logs

No response

System Info

Version: 4.19.0

Severity

I can work around it

@edgarGracia edgarGracia added the bug Something isn't working label Feb 16, 2024
@skye0402
Copy link

I think this is the same like #7189

@aliabid94
Copy link
Collaborator

taking a look

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

Successfully merging a pull request may close this issue.

3 participants