Are you running that from an sp-button? I had the same issue with the folder picker running from sp-buttons. The event listener semmed to run in an infinite loop. Switching to a native HTML button fixed it. I posted about this a few months ago and other had the same problem too.
Since that time, I implemented a fix for the space and enter key focus issue. I then tried this with sp-buttons again for the folder picker and it also solved the folder picker issue too. I think the button was triggering again when the user clicked to select a folder which is why the folder picker kept opening again. The “nofocus” fixed Kerri Shots gave me in this post fixed the issue.