#8198·streamlit

Bugs when using chat_input() with st.empty()

Author: ylf-NgCreated Feb 25, 2024Updated Sep 16, 2026
Labelstype:bugstatus:confirmedpriority:P3feature:st.chat_input

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

I try to replace the chat_input with another placeholder in st.empty, it works in v1.30.0, but it doesn't work properly in v1.31.1

Reproducible Code Example

import streamlit as st

# it doesn't work
placeholder = st.empty()
user_input = placeholder.chat_input(placeholder="your first question")
if user_input:
    st.write(f"text input: {user_input}")
    user_input = placeholder.chat_input(placeholder="your second question")

# it works
placeholder = st.sidebar.empty()
user_input = placeholder.chat_input(placeholder="your first question in sidebar")
if user_input:
    st.write(f"text input: {user_input}")
    user_input = placeholder.chat_input(placeholder="your second question in sidebar")

Steps To Reproduce

just run above code and try to input something.

Expected Behavior

the second chat_input widget should replace the first chat_input.

Current Behavior

st.empty() is not working

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version:1.31.1
  • Python version:3.8.16
  • Operating System:ubuntu
  • Browser:chrome

Additional Information

No response