First port of call.
The culprit turns out to be Viewer_Select.js
Interestingly, I am developing a script that keeps track of the "current" file within a group of files using the excellent dlg.WatchTab capability which wasn't available back in 2017 when the Viewer Select script was written.