Always hide "greyed out" elements (where [stale-data='true'])

Hello,

I have a big complex form with fields constantly being added and removed based on another element just above the form. When I remove some form fields, the old fields along with a “submit button” stay, even if greyed out.

Usually this is fine as, once the page finishes running, the greyed out fields go away.

However they are not going away in this case:

So I thought, why not try to just hide them on the frontend? They can be isolated with the CSS query selector, in Javascript

let elsToHide = document.querySelectorAll(“[stale_data=‘true’]”);

The questions is how can I hide them? Or is there a better way to do this in CSS? I looked at streamlit_js_eval but that seemed better-suited for getting values into Python, for example screen height and width.