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

onChange event not working on Streamlit 1.34 #35

Open
dectoplate opened this issue May 21, 2024 · 7 comments
Open

onChange event not working on Streamlit 1.34 #35

dectoplate opened this issue May 21, 2024 · 7 comments

Comments

@dectoplate
Copy link

onChange event is not working after Streamlit 1.34 release.

@vikvikvr
Copy link

@okld is this repo still mantained?

we love your library and use it extensively throughout our projects
Unfortunately this issue prevents us from upgrading Streamlit 😣

Thanks! 😀

@shuZro
Copy link

shuZro commented Jun 16, 2024

Bump

@moonbug-car
Copy link

moonbug-car commented Jun 17, 2024

Bump x2
@okld it would be great if you could update it, Thank You.

@KhabarovaNina
Copy link

Bump
@okld please!

@KhabarovaNina
Copy link

Hello!

This issue is related to the refactoring of streamlit in using custom components.

It is possible to restore the previous functionality by replacing in the file /streamlit_elements/core/callback.py:
# from streamlit.components.v1 import components - OLD
from streamlit.components.v1 import custom_component as components - NEW

However, I hope the streamlit developers will fix this issue in future releases.

@vikvikvr
Copy link

Thanks @KhabarovaNina a lot!

I made a small script to patch it automatically (needed for our Docker builds), hope it helps other people :)

import os
import streamlit_elements
import re

def patch_streamlit_elements():

    # issue: https://github.com/okld/streamlit-elements/issues/35
    relative_file_path = 'core/callback.py'
    library_root = list(streamlit_elements.__path__)[0]
    file_path = os.path.join(library_root, relative_file_path)

    # Read broken file
    with open(file_path, 'r') as file:
        lines = file.readlines()

    broken_import = 'from streamlit.components.v1 import components'
    fixed_import = 'from streamlit.components.v1 import custom_component as components\n'

    # Fix broken import line
    for index, line in enumerate(lines):

        if re.match(broken_import, line):
            print(f'Replaced broken import in {file_path}')
            lines[index] = fixed_import

    # Update broken file with fix
    with open(file_path, 'w') as file:
        file.writelines(lines)


if __name__ == "__main__":
    patch_streamlit_elements()

@Yeqishen
Copy link

vikvikvr

This is awesome, vikvikvr, thank you very much, the script still works great! 👍

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

No branches or pull requests

6 participants