I have a page with a JavaScript based idle sign off script as well as a file upload feature. I noticed that if I opened the dialog then allowed the idle sign off to trigger a redirect to the login page the open file dialog remained open. I would have expected it to be closed when the originating page is unloaded.
Given an input with type of file:
<input type="file" name="file" />
If the user clicks and opens the native file picker dialog window but while it is open the page or frame is redirected via a script the dialog does not close. A script like this should duplicate the behavior:
$('input[type=file]').on('click', function(){
setTimeout(function(){
window.location.href = "some other page";
}, 2000);
});
You can see the behavior here: https://jsfiddle.net/we40rpfs/1/
I was able to reproduce this in on Windows10 in IE Edge, Chrome 86.0.4240.198 and Firefox 82.0.2.
Interestingly in IE and Chrome the file picker host also crashes sporadically when the user attempts to close or cancel the dialog. Firefox might also crash it as well but I was unable to see it happen.
Is there any way to detect that this dialog is open and programmatically close it before redirecting?