Summary
I am using click_detector and containers and get a duplicate of click_detector after clicking the first time.
Steps to reproduce
Code snippet:
import streamlit as st
import pandas as pd
from st_click_detector import click_detector
from time import sleep
def empty():
placeholder.empty()
sleep(0.01)
placeholder = st.empty()
content = """<p><a href='#' id='Link 1'>First link</a></p>
<p><a href='#' id='Link 2'>Second link</a></p>
<a href='#' id='Image 1'><img width='20%' src='https://images.unsplash.com/photo-1565130838609-c3a86655db61?w=200'></a>
<a href='#' id='Image 2'><img width='20%' src='https://images.unsplash.com/photo-1565372195458-9de0b320ef04?w=200'></a>
"""
empty()
with placeholder.container():
clicked = click_detector(content, key='main')
if clicked == 'Image 1':
st.header('Second')
st.write('here')
elif clicked == 'Image 2':
st.header('Third')
st.write('here2')
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Expected behavior:
I would expect the images to stay at the top in the container and if either image 1 or image 2 is clicked, that the code within those if statements be shown
Actual behavior:
Sometimes I am seeing duplicated images, sometimes I only see one set of images. I am not clear on how it is duplicating, as I am clearing it before putting information in the container.
Debug info
- Streamlit version: Streamlit, version 1.24.0
- Python version: Python 3.7.8
- OS version: Mac Ventura 13.4
- Browser version: Google Chrome Version 114.0.5735.198
Requirements file
I was using Visual Studio Code to write the original code. But once I deployed it, I started experiencing bugs that I did not see in VSCode.
Links
- Link to your GitHub repo: GitHub - celenaaponce/ASL_espanol
- Link to your deployed app: https://aslespanol.streamlit.app/Diccionario_por_Letra