Session State management lagged in st.form

Using Streamlit 1.40.0 and Python 3.11.10, I seemed to have encountered a bug with st.text_area inside of st.form. Below is my code:

import streamlit as st

with st.form("form"):
    test_text = st.text_area("test", key="test input")
    submitted = st.form_submit_button("submit")

if submitted:
    st.write(st.session_state)

What I would expect, per the behavior in previous streamlit versions, is when I ctrl+enter, it updates session state as you would expect it to while submitting the form. However it seems to be delayed. If you write in the text box, ctrl enter, it will have no text. You would have to edit the text again, then ctrl enter again, to get the text from the first edit.


Using the form submit button has the desired behavior though.

Confirmed with python 3.12 too.