the new collection was (sometimes?) not empty, it contained some (all?) elements of the old one. If it was selected in the folder tree the focus would still be on it. Now the focus jumps to the File Collections node as it should.
Looks like the problem hasn't gone away completely.
I ran the script that updates the collection Parentfolders and opens it in a new tab. This collection had already been open in two tabs. One of the old tabs showed the right content after a refresh, but the other one refuses to update and the folders it contains can actually be opened.
From a quick look, there's a general issue where tabs will continue to show old collections if the collection is deleted under them.
The active tab may jump to another collection, or up to the File Collections parent, but it's not really the tab doing it; it's a result of the folder tree removing the deleted branch and needing to select something else. (If the tree is turned off, you get the same result in both active and inactive tabs.)
We should be able to fix this by making the tabs parent up a level, the same as if they were in a normal folder which was deleted.