In order to better express the problem, you can see the gif:
I’m not sure if this is specific to y-prosemirror. The selection probably lost because the editor doesn’t have focus anymore. But I’d be happy to receive a fix for this in y-prosemirror if the fix is not to hacky.
Yjs is open source software with no strings attached. I maintain this forum, and all related modules at my own expense. If you want me to work on this issue you can sponsor me: https://github.com/sponsors/dmonad
I allocate some time for my sponsors. If you have a support contract I will fix your issues ASAP.