text: Title: The popover doesn't hide when it's inside a fragment and depends on another widget to be visible.
  Body: ### Checklist
  
  - [X] I have searched the [existing issues](https://github.com/streamlit/streamlit/issues) for similar issues.
  - [X] I added a very descriptive title to this issue.
  - [X] I have provided sufficient information below to help reproduce this issue.
  
  ### Summary
  
  When I add a `popover` that depends on another widget to be visible, once it becomes visible, it never hides again.
  
  
  
  ### Reproducible Code Example
  
  ```Python
  from dataclasses import dataclass
  from typing import Union
  
  import streamlit as st
  
  
  @dataclass
  class Test:
      name: str = "Test"
      child: Union["Test", None] = None
  
      @st.experimental_fragment
      def show(self):
          content_container, config_container = st.columns([1, 1])
          with content_container:
              st.write(f"This is the content of {self.name}")
          with config_container:
              with st.popover("Config"):
                  st.write("This is the config")
          if st.toggle(label="Show child", key=self.name):
              self.show_child()
  
      def show_child(self):
          if self.child is None:
              st.write("No child")
              return
          self.child.show()
  
  
  Test(child=Test("Child")).show()
  ```
  
  
  ### Steps To Reproduce
  
  1. Initial state
  ![image](https://github.com/user-attachments/assets/571dec6d-699b-4e82-84b0-de8dae4f4002)
  2. Enable the `toggle`
  ![image](https://github.com/user-attachments/assets/d1f7dbd5-89b3-49c6-81bd-afe7ee2227df)
  3. Disable the `toggle`
  ![image](https://github.com/user-attachments/assets/e3f57bbe-8e94-4b21-ab7b-e5fd3342a270)
  
  
  ### Expected Behavior
  
  I expect the `popover` the be visible only if the `toggle` is enabled.
  
  ### Current Behavior
  
  The `popover` remains visible but "disabled" if it has been rendered at least once and the `toggle` is disabled.
  
  ### Is this a regression?
  
  - [ ] Yes, this used to work in a previous version.
  
  ### Debug info
  
  - Streamlit version: 1.36.0
  - Python version: 3.11.10
  - Operating System: WSL Ubuntu 22.04.5 LTS
  - Browser: Chrome
  
  
  ### Additional Information
  
  _No response_