bug: text_input with caching
See original GitHub issueSummary
Using a cached value as text_input value, text doesn’t get updated unless focus changes. I use caching a lot to support more complicated scenarios.
Steps to reproduce
2- write something hit enter 3- write something else (without changing focus) hit enter
Code snippet:
import streamlit as st
from streamlit.report_thread import get_report_ctx
def query_cache(q=None):
ctx = get_report_ctx()
session_id = ctx.session_id
session = st.server.server.Server.get_current()._get_session_info(session_id).session
if not hasattr(session, "_query_state"):
setattr(session, "_query_state", "default")
if q is not None:
session._query_state = q
return session._query_state
# if st.button('reset'):
# value = ""
# query_cache("")
value = query_cache()
my_input=st.text_input("Input", value)
c=query_cache(my_input)
st.write(c)
Expected behavior:
should work the same as text_input without caching.
Actual behavior: 1- type ‘poo’ enter 2- type ‘poop’ enter (doesn’t update result, loses focus) 3- after focus change write ‘poop’ again. It works
Is this a regression?
no
Debug info
- Streamlit version: 0.80.0
- Python version: 3.6.9
- OS version: ubuntu 18.04
- Browser version: chrome & firefox latest
Additional information
I’m caching the text_input values because I want to have a button clear them (commented out in code example) Solutions that don’t use caching and also allow me to reset with a button, while also being not buggy with text_input are also welcome.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Bug - Input cached when not immediately consumed by a State
My rough, high-level understanding is that the Protagonist class stores input from the InputReader and relays it to the State Machine which ...
Read more >Form Textbox Caching Problem - Stack Overflow
I have a PHP form, with various input fields and textboxes. If you submit and go back, all of the data that was...
Read more >1747835 - Cache text input type - Bugzilla@Mozilla
Bug 1747835 - P2: Cache text-input-type attribute for text and date/time inputs. r?morgan. 10 months ago. Eitan Isaacson [:eeejay].
Read more >TurboLinks and caching form inputs · Issue #574 - GitHub
TURBOLINKS BFCACHE: After pressing the back button, users input is NOT cached. The form is reset to it's original default state. Summary. Is ......
Read more >Thread: Caching problem across jobs with 'Text file Input' step.
Caching problem across jobs with 'Text file Input' step. I am building a URL in a JavaScript step, which returns data in CSV...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi folks, even using the workaround with session state I find the same issue
still results in the previous issue. Am I doing something wrong?
Thanks for the report @cceyda ! I believe our solution with our implementation of Session State will help on this. I tagged this issue to the project so that when it’s released, we can follow up with a solution!