Steamlit elements calling OnClick running without click

Thank you for your thought. It stops the running immediately, but now when I press the button, or use the same function in a hot key event callback, all it does is reload the entire page without any update.

I’ve even added print statements and st.write in the function and it doesn’t seem to run when clicked.

The workaround is here but now I am getting another error regarding

“Calling st.rerun() within a callback is a no-op.”