gagan3012 / streamlit-tags

Custom Tag component for streamlit
https://streamlit-tags.readthedocs.io/en/latest/
MIT License
291 stars 18 forks source link

Component keeps refreshing when using dynamic custom values #2

Open liorshk opened 3 years ago

liorshk commented 3 years ago

Describe the bug Component keeps refreshing when using dynamic custom values

To Reproduce

import random
randomlist = []
for i in range(0,5):
    n = random.randint(1,30)
    randomlist.append(n)
search_keywords = st_tags('Keywords:', 'Press enter to add more', randomlist)
gagan3012 commented 3 years ago

Hello, Currently, the component only accepts static lists I am working on a fix to enable custom values. Please star the repo if you liked streamlit-tags

babuus commented 1 year ago

is there any update on this?

Jyothipyxis commented 8 months ago

I am facing the same issue, is there any update on the fix ?

CHerSun commented 8 months ago

I believe that's how Streamlit works. It hashes component based on all initial values - labels, starting values, options list, key, etc. If any of that changes - Streamlit treats the component as a new one, thus, refreshes it completely. Streamlit works like this for its core components, but I'm pretty sure 3rd party components are treated in the same way, judging from my experience.

That's one of the reasons, why selected value is stored in session_state, if component key is specified - to be able to programmatically change selected item / value (before component is rendered). Not all 3rd party components support that though.