Update accordion from backend#2690
Merged
Merged
Conversation
Contributor
|
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2690-all-demos |
Member
|
Thanks @freddyaboulton! Is this ready to be reviewed or still a draft PR? |
Collaborator
Author
|
@abidlabs Opened now! Was waiting for CI |
Member
|
Works great with top-level accordions, but I'm getting some interesting behavior with nested accordions. It seems that when you programmatically toggle the inner accordion, the outer accordion collapses if it is open? Here's an example for reproduction: import gradio as gr
with gr.Blocks() as demo:
with gr.Accordion(label="Open for greeting", open=False) as accordion:
gr.Textbox("Hello!")
with gr.Accordion(label="Inner", open=False) as inner:
gr.Textbox("hi")
open_btn = gr.Button(value="Open Accordion")
close_btn = gr.Button(value="Close Accordion")
open_btn.click(
lambda: gr.Accordion.update(open=True, label="Open Accordion"),
inputs=None,
outputs=[inner],
)
close_btn.click(
lambda: gr.Accordion.update(open=False, label="Closed Accordion"),
inputs=None,
outputs=[inner],
)
demo.launch()Here's what I see: |
Member
|
Probably a front end issue. Will take a look. |
…/gradio into 2668-update-accordion-backend
Collaborator
Author
pngwn
reviewed
Nov 28, 2022
pngwn
approved these changes
Nov 28, 2022
Collaborator
Author
|
Thank you all for the reviews 🤗 |
7 tasks
|
I have multiple Accordions in my code, and I want to ensure that when I toggle one Accordion open, the others automatically close. Here's the current code I have: ` ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Fixes #2668 .
I don't think I'll be able to address any feedback until I come back so feel free to push commits + merge without me!
Would be good to add a front-end test for this as well.
To test:
Checklist:
A note about the CHANGELOG
Hello 👋 and thank you for contributing to Gradio!
All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.
Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by
[@myusername](link-to-your-github-profile)in[PR 11111](https://github.com/gradio-app/gradio/pull/11111)".If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.