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

Condition Tree does not accept updated config when using a key #7

Open
matt-gree opened this issue Jul 23, 2024 · 1 comment
Open

Comments

@matt-gree
Copy link

When setting a key for the condition_tree(), upon rerunning the app and updating the config (i.e. table changes), the dropdown of available fields does not change. Even deleting the session state key before calling condition_tree() does not change the available fields.

Code:

config = config_from_dataframe(table)

# Optional, does not affect results
if 'condition_tree' in st.session_state:
        del st.session_state['condition_tree']

 query_string = condition_tree(config,
        min_height = 400,
        placeholder = 'No rules created',
        always_show_buttons = True,
        key = 'condition_tree'
        )

Basically, even if my table changes in this code, the condition tree will still hold on to the old config. This does not happen when not using a key. My intention with using the key is to be able to save the query and recall it at a different time.

@cedricvlt
Copy link
Owner

Hi @matt-gree,

This is a normal behaviour using the key; the component will not be re-mounted when its arguments are changed. You can force it to be re-mounted by changing dynamically the key value. It will update the config with the right dropdown fields, but it will also reset the tree.

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

2 participants