Linking 2 widgets together

Hi all, I’m trying to link 2 widgets together using the SessionState object found in A possible design for doing per-session persistent state in Streamlit · GitHub

Basically I’m trying to have a date_input widget that gets dynamically adjusted based on a selectbox with easier to read options like "Last 7 days", "Last 30 days", etc. If you select the last 7 days, then the date_input should adjust accordingly and if you select 2 dates that fall within the last 30 days, then the selectbox should update accordingly.

I’ve only tested the one way (pick from the selectbox which updates the date_input) and there seems to be some sort of delay where you need to actually pick the same option twice (see attached gif)… is there a reason for this?

P.s. I’m more of an R Shiny person and it would be cool to have the same functionality as Shiny’s updateInput_() type function without trying to manipulate state objects.

Thank you.

Gist with the code: Test dynamic widgets · GitHub

$ streamlit --version
Streamlit, version 0.79.0
$ python --version
Python 3.8.7