question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

st.slider returns an old value

See original GitHub issue

Summary

Type here a clear and concise description of the bug. Aim for 2-3 sentences.

Steps to reproduce

What are the steps we should take to reproduce the bug:

  1. Run this script:
max_val = st.selectbox("max", [5, 10, 15], 0)
val = st.slider("main", 0,  max_val, 0)
st.write(val)
  1. Change the value of the “main” slider to 3
  2. Change the value of the “max value” to 10
  3. Change back the value of the “max” value to 5

Expected behavior:

The value of the st.write is 0, consistent with the default value of the “main” value and its current value.

Actual behavior:

The value of the st.write is 3 (old value)

Is this a regression?

?

Debug info

  • Streamlit version: c2e9d6b0c268f986c2c8588e36bdec08e47f194e Python 3

Additional information

Interestingly, this does not repro if fromUi in

 this.setWidgetValue({ fromUi: false })

in componentDidMount in Slider.tsx is set to true instead of false.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
kmcgradycommented, May 23, 2021

Our solution to this should be resolved with session state. I’ve tagged this issue in it to verify when we release.

1reaction
dchudzcommented, Jan 17, 2020

I spent a few minutes digging into the history so in case this saves anyone time: #349 was reverted by #753.

(I got here via https://discuss.streamlit.io/t/preserving-state-across-sidebar-pages/107/10 and FWIW it would help me out a lot for this bug to be addressed.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

st.slider - Streamlit Docs
The current value of the slider widget. The return type will match the data type of the value parameter. Examples. age = st.slider('How ......
Read more >
Get the previous selection of a slider in streamlit - Stack Overflow
I have a range slider for years. The problem now is, that I want to have the previous selection of this slider. After...
Read more >
How to add a slider in streamlit - ProjectPro
You can add a slider to your Streamlit app using "st.slider". ... value -> It is the value that is displayed on the...
Read more >
Streamlit from Scratch: Build a Data Dashboard with ...
The st.slider method requires three parameters, a prompt string, and two numerical limits. The return value is one that is between the ...
Read more >
Data Visualization with Streamlit - Part II - Topcoder
1 2 st.text_input("Your name", key = "name") st.write("Welcome to you ... The slider method returns the current value of the slider widget.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found