Just as I thought, the lines you commented out were responsible for hiding the camera once un-selected. By removing those, the viewport is never removed and you’ll always see the last camera you clicked.
That’s a workaround and it works, but it’s not a proper fix, because each time you select the camera (or a different one), a new viewport is created on top of the other one, so you’ll end up with lots of viewports and that would eventually slow up the editor.
Without removing those lines, the problem is the editor removes all the viewports the user might have created so my component won’t work until this is fixed.
For now having those lines removed allows for the functionality you needed so until there’s a fix it should be ok to do that. It would take a while until you notice a substantial slowdown anyway, but bear in mind that performance might degrade.
Anyway, I’ve made a small script that draws a viewport with the camera it’s attached to anywhere on the screen. That would allow for more functionality like dislpaying the contents of multiple cameras if needed, and allow the user to customize the size of the viewport as well. Once I find a fix for this I’ll post it on the Code Exchange section of the forum! For now I guess the workaround is good enough?