fregante / GhostText

👻 Use your text editor to write in your browser. Everything you type in the editor will be instantly updated in the browser (and vice versa).
https://GhostText.fregante.com
MIT License
3.25k stars 116 forks source link

Focus browser after disconnection #176

Closed luisherranz closed 3 years ago

luisherranz commented 3 years ago

As I already informed in https://github.com/GhostText/GhostText/pull/175, the new codebase (https://github.com/GhostText/GhostText/issues/172) is working great for me in Chrome + VimR.

The only thing I miss was the automatic focus of Chrome when the socket is disconnected. It used to work that way in the old codebase and it is nice because you can use the same shortcut to go back and forth between Chrome and the editor without touching your mouse 🙂

I have used the same code that was used in the old codebase for this.

fregante commented 3 years ago

deactivate is called from the background in most cases, so it doesn't make sense to send a message back. It's best to just call the tabs.update functions from the background in case of error and disconnection.

subnut commented 3 years ago

That behaviour was nice because we could only select one field at a time. I don't think that feature would be appreciated by people who regularly have many fields connected simultaneously.........

:shrug:

fregante commented 3 years ago

Great point, I didn't think about that. At most it should wait for activeFields.size === 0, so perhaps the current setup is almost right, with this exception.

luisherranz commented 3 years ago

I think it should always set the focus back to Chrome because when you finish working on a field, you want to send it. If the focus goes back to Chrome, the only thing left is to press Enter.

fregante commented 3 years ago

This can be made an option if anyone finds it annoying.

luisherranz commented 3 years ago

Awesome. Thanks @fregante :)