Aggrid not working with multiple expanders

I have an app that has multiple pages, each of which has an Aggrid element hidden inside an expander. If I switch between pages and expand these, I find the Aggrid object often doesn’t load unless I manually rerun the page. I tried to make a minimal example here, using a toggle to simulate multiple pages. (the “working example” can be commented out, it’s just to show what’s necessary to reproduce the issue)

import streamlit as st
from st_aggrid import AgGrid
import pandas as pd

data = {
    'System Name': ['System A', 'System B', 'System C', 'System D'],
    'Value 1': [10, 20, 30, 40],
    'Value 2': [1, 2, 3, 4]
}
df = pd.DataFrame(data)

# this works 
if st.toggle("Expander and non-expander"):
    st.write("some text (toggle on)")
else:
    with st.expander("Expand (toggle off)"):
        AgGrid(df, key="aggrid1")

# this breaks - aggrid element often won't appear when expanded
if st.toggle("Expander and expander"):
    with st.expander("Expand (toggle off)"):
        AgGrid(df, key="aggrid2")
else:
    with st.expander("Expand (toggle on)"):
        st.write("some text (toggle on)")

Go to the official repository and check your issue there. If there is none, create an issue there. Be sure to mention the streamlit version you used.

I’ve added an issue there as you mentioned, although it doesn’t seem like the issues from the last several months are being tracked by anyone, so I’m not too hopeful for a response soon. If anyone here has any thoughts let me know.