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

gradio 5.0 unable to load javascript file #10267

Open
1 task done
git-hamza opened this issue Dec 30, 2024 · 2 comments
Open
1 task done

gradio 5.0 unable to load javascript file #10267

git-hamza opened this issue Dec 30, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@git-hamza
Copy link

git-hamza commented Dec 30, 2024

Describe the bug

if I provide JavaScript code in a variable, it is executed perfectly well but when I put the same code in a file "app.js" and then pass the file path in js parameter in Blocks, it doesn't work. I have added the code in reproduction below. if the same code is put in a file, the block will be unable to execute that.

It was working fine in version 4. Now I am upgrading to 5.0.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

login_page_js = """
() => {
    //handle launch
    let reload = false;
    let gradioURL = new URL(window.location.href);
    if(
        !gradioURL.searchParams.has('__theme') ||
        (gradioURL.searchParams.has('__theme') && gradioURL.searchParams.get('__theme') !== 'dark')
    ) {
        gradioURL.searchParams.delete('__theme');
        gradioURL.searchParams.set('__theme', 'dark');
        reload = true;
    }
    if(reload) {
        window.location.replace(gradioURL.href);
    }
    
}
"""

with gr.Blocks(
    js = login_page_js
) as login_page:
        gr.Button("Sign in with Microsoft", elem_classes="icon-button" ,link="/login")

if __name__ == "__main__":
    login_page.launch()

Screenshot

No response

Logs

No response

System Info

linux 2204

Severity

I can work around it

@git-hamza git-hamza added the bug Something isn't working label Dec 30, 2024
@abidlabs
Copy link
Member

Hi @git-hamza can you please provide a minimal code example that we can use to reproduce the issue above? See: https://stackoverflow.com/help/minimal-reproducible-example

@abidlabs abidlabs added the needs repro Awaiting full reproduction label Dec 30, 2024
@git-hamza
Copy link
Author

Thankyou @abidlabs . I have edited and added the reproduction code, you will be able to run the above example successfully and your page will shift to dark theme, but when you shift the same code to a file and provide file path in js, it will not work.

@abidlabs abidlabs removed the needs repro Awaiting full reproduction label Dec 30, 2024
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

No branches or pull requests

2 participants