Skip to content

Fix infinite requests when doing tab item select#2070

Merged
abidlabs merged 3 commits into
mainfrom
2069-infinite-api-requests
Aug 27, 2022
Merged

Fix infinite requests when doing tab item select#2070
abidlabs merged 3 commits into
mainfrom
2069-infinite-api-requests

Conversation

@freddyaboulton
Copy link
Copy Markdown
Collaborator

@freddyaboulton freddyaboulton commented Aug 23, 2022

Description

Fixes #2069

To test, run the reproducer and switch tabs successfuly. blocks_plug also works as expected.

import gradio as gr
    
tab_names = ["one", "two"]

with gr.Blocks() as demo:

    with gr.Tabs():
        for name in tab_names:
            with gr.TabItem(name) as rl_tab:
                num = gr.Number()
                rl_tab.select(lambda: 3, inputs=[], outputs=[num])

demo.launch()

Don't think this breaks anything but would be good to get the opinion of a front-end expert.

Checklist:

  • I have performed a self-review of my own code
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@github-actions
Copy link
Copy Markdown
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2070-all-demos

<button
class="px-4 pb-2 pt-1.5 border-transparent text-gray-400 hover:text-gray-700 -mb-[2px] border-2 border-b-0"
on:click={() => (selected = t.id)}
on:click={() => change_tab(t.id)}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

TBH not sure how the old code was causing the original problem but it seems to be fixed now 😬

@freddyaboulton freddyaboulton marked this pull request as ready for review August 23, 2022 22:23
@abidlabs
Copy link
Copy Markdown
Member

Can confirm that the demos work, but it would be good to get some confirmation from the front end team: @aliabid94 @dawoodkhan82 @pngwn?

@abidlabs abidlabs merged commit 6219dc7 into main Aug 27, 2022
@abidlabs abidlabs deleted the 2069-infinite-api-requests branch August 27, 2022 22:06
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.

Infinite api requests when updating a component inside a tab on tab select

2 participants