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

Fix JS call #4486

Merged
merged 2 commits into from Jun 13, 2023
Merged

Fix JS call #4486

merged 2 commits into from Jun 13, 2023

Conversation

aliabid94
Copy link
Collaborator

@aliabid94 aliabid94 commented Jun 12, 2023

the _js parameter would not show updates to components in the cases where both:

  • there was no accompanying backend python function
  • all updated values were values only, and not gr.update JSONs

The reason for this is the line to cause svelte to re-render (root_node = root_node) was for some reason only in the code when gr.update were loaded, or there was an update to a status-tracker. All backend python functions make status-tracker updates, so if there's any python function then it always updates. Simply moving the re-render line to run after any update should fix this. Test with

import gradio as gr

with gr.Blocks() as demo:
    a = gr.Textbox()
    c = gr.Button()
    c.click(None, None, a, _js="() => {console.log('abc'); return ['abc'];}")

demo.launch()

Closes: #4485

@gradio-pr-bot
Copy link
Contributor

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

@abidlabs abidlabs requested a review from pngwn June 12, 2023 22:25
@pngwn
Copy link
Member

pngwn commented Jun 12, 2023

I probably broke this.

Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

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

Code looks good. Can't test right now.

@freddyaboulton
Copy link
Collaborator

I was able to test and it works so if @pngwn says the code looks good then this can be merged once CI passes @aliabid94 !

@abidlabs
Copy link
Member

I'll merge this in so that I can use it for #4456. Quick turnaround!

@abidlabs abidlabs closed this Jun 13, 2023
@abidlabs abidlabs reopened this Jun 13, 2023
@abidlabs abidlabs merged commit bda25eb into main Jun 13, 2023
33 of 37 checks passed
@abidlabs abidlabs deleted the fix_js_call branch June 13, 2023 00:24
@abidlabs abidlabs mentioned this pull request Jun 13, 2023
@luoweb luoweb mentioned this pull request Aug 9, 2023
1 task
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.

_js does not update outputs for certain return values
5 participants