Streamlit resetting the Slider for v0.84.1

The slider automatically resets itself when I updated the streamlit from v0.83 to v0.84.1, I didn’t do any code changes, earlier, the slider used to stay to the position where it has been positioned. Now it gets back to its initial position. I need to use the Session state for my current project, so I can’t go back to the v0.83

slider-reset (1)

Slider code I am using :

            slider = st.slider(
                label='', min_value=1,
                max_value=_dfmax, key='my_number_prediction_slider')

Please help to fix this issue.

What was happening before with streamlit==0.83:

1 Like

Hi @rhnfzl ,

Welcome to the Streamlit Community :balloon:

We want to try to reproduce the error on our end. In the following lines of code:

            slider = st.slider(
                label='', min_value=1,
                max_value=_dfmax, key='my_number_prediction_slider')

how are your populating _dfmax ?

Also, a working minimal example with some dummy data would really help.



Hello @abhi ,

Thank you for the reply. The problem is with the select_slider not with the slider, my apologies for the confusion. I was able to work out a stripped-down code with the dummy data. Also, today I upgraded the streamlit from v0.84.1 to v0.84.2 and the issue still exists.

import sys
import streamlit as st
import pandas as pd

data = [['TX', 'X', '2018-07-19 06:14:18+00:00', 'Role 2'],
['TX', 'Y', '2018-07-19 06:28:03+00:00', 'Role 5'],
['TX', 'Z', '2018-07-19 06:28:31+00:00', 'Role 2'],
['TX', 'A', '2018-07-19 06:34:00+00:00', 'Role 4'],
['TX', 'C', '2018-07-19 06:34:00+00:00', 'Role 4'],
['TX', 'B', '2018-07-19 09:33:56+00:00','Role 1'],
['TX', 'A', '2018-07-19 18:00:00+00:00','Role 4'],
['TX', 'C', '2018-07-21 06:00:00+00:00','Role 4'],
['TX', 'A', '2018-07-21 06:00:00+00:00', 'Role 4'],
['TX', 'A', '2018-07-23 06:00:00+00:00', 'Role 4'],
['TX', 'C', '2018-07-23 06:00:00+00:00', 'Role 4'],
['TX', 'C', '2018-07-24 06:00:00+00:00', 'Role 4'],
['TX', 'A', '2018-07-24 06:00:00+00:00', 'Role 4'],
['TX', 'C', '2018-07-27 06:00:00+00:00', 'Role 4'],
['TX', 'A', '2018-07-27 06:00:00+00:00', 'Role 4'],
['TX', 'E', '2018-07-27 12:00:00+00:00', 'Role 6']]

def main(argv, filter_parms=None, filter_parameter=None):

    #Dashboard Title
    st.title("⏭️Next Event Prediction Dashboard")
    st.sidebar.title("🎛️ App Control Menu")

    if not argv:

        _folder_name  = st.sidebar.text_input('Any Random Text')

    def next_columns(filter_log):
        filter_caseid = st.selectbox("🆔 Select Case ID", filter_log["caseid"].unique())
        filter_caseid_attr_df = filter_log.loc[filter_log["caseid"].isin([filter_caseid])]
        return filter_caseid, filter_caseid_attr_df

    if _folder_name != "":

        # Read the Test Log
        filter_log = pd.DataFrame.from_records(data, columns=['caseid', 'task', 'timestamp', 'role'])
        filter_log = filter_log.astype({'caseid': object})

        essential_columns = ['task', 'role', 'timestamp']

        filter_caseid, filter_caseid_attr_df = next_columns(filter_log)
        filter_caseid_attr_ = filter_caseid_attr_df[essential_columns].values.tolist()

        filter_caseid_attr_list = st.select_slider("Choose [Activity, User, Time]", options=filter_caseid_attr_, key="_slider")

        _idx = filter_caseid_attr_.index(filter_caseid_attr_list)

if __name__ == "__main__":

And the screencast of the above code:


Please let me know if you need anything else, Thank You.

@rhnfzl : Thanks for sharing the example.

I was able to isolate the cause of this issue and it looks like a bug in Streamlit. I’ve filed an issue for our dev team and we’re looking into it: st.select_slider is resets its state upon interaction(v0.84) · Issue #3600 · streamlit/streamlit · GitHub

Thanks @abhi :slight_smile:

Fixed in Streamlit v0.86.0

1 Like