Closing popout window with active notices creates orphaned notices upon next notice

Steps to reproduce

  1. In the sandbox vault, open a popout window containing a link to another note
  2. Right-click the link and rename the file, updating existing links
  3. Close the popout while the notice(s) about updating links are still visible
  4. From the main window, do another link rename, or some other action to trigger a notice

Did you follow the troubleshooting guide? [Y/N]

Y

Expected result

Only the new rename (or other) notice(s) should appear

Actual result

The notice(s) that were present when the popout was closed will appear above the new ones. The new ones then disappear, but the old ones remain, and can’t be removed even by clicking on them.

Environment

SYSTEM INFO:
Obsidian version: v1.9.14
Installer version: v1.9.12
Operating system: Windows 10 Pro 10.0.19045
Login status: logged in
Language: en
Catalyst license: supporter
Insider build toggle: off
Live preview: on
Base theme: light
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information

The initial lack of removal appears to be due to using activeWindow.setTimeout(), but not having a way to detect that the window has been closed. My initial thought was that this could probably be fixed with a one-time onWindowMigrated() hook on the notice’s containerEl to set a new timer in the new window for the remaining elapsed time, if any.

However, the inability to remove by clicking makes it appear that closing a window removes all the event listeners from anything mounted in its DOM, so that wouldn’t actually work. Probably the simplest solution is that a window’s onbeforeclose needs to detach the notice container if it’s present in the popout, and perhaps remove all its children.