Fullscreen composer keyboard shortcut works only once

AI-generated summary

Users reported that the Shift+F11 keyboard shortcut for toggling fullscreen in the Discourse composer only worked once — specifically, it could exit fullscreen but not enter it, unless the fullscreen button was clicked first. TheBestPessimist also noted erratic behavior when rapidly pressing Shift+F11 during animations. sam confirmed the issue on Chrome and Firefox using a Microsoft Sculpt keyboard, suggesting a potential shortcut change. Johani explained the root cause: the composer title input steals focus upon opening, blocking the shortcut unless focus is manually moved away. Even the composer body textarea interferes when focused. While Mousetrap offers a workaround (adding a mousetrap class), it risks breaking other shortcuts. Johani later confirmed the issue was resolved by pmusaraj via PR #6907, allowing Shift+F11 to work regardless of input focus. Thanks were extended to TheBestPessimist for reporting the bug.

It seems i cannot go to fullscreen by pressing shift+f11 but only exit the fullscreen. (i have to press the fullscreen button first).

It’s also weird that when the editor is in fullscreen if i keep shift pressed then quickly keep pressing f11 multiple times, the editor goes full ↔ not full as long as the previous animation was not finished.

Happens here on meta, on chrome.

2 Likes

Hmmm I can even get SHIFT F11 to work here either to open or close fullscreen.

Using this keyboard on Windows, tested on Chrome and Firefox.

@Johani can you have a look, I wonder if we should pick a different shortcut here.

3 Likes

The reason this happens is because the composer title steals focus when the composer is opened.

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/templates/composer.hbs#L62

So when you use the shortcut, you’re using it while the input is focused and that’s why it doesn’t work. You’d need to click somewhere outside to remove the focus from the input. Although slightly less obvious, the composer body text area - if focused - will also interfere with the shortcut.

When you enter full screen mode the title input is removed, when you exit, it gets re-inserted and steals focus again. This is why this occurs

Mousetrap has a way to handle this, to add a mousetrap class to the markup of those elements, the shortcut would then fire even if the inputs are focused, but so will all the other keyboard shortcuts and it creates a lot more problems than it solves.

Sure, just let me know what works for you.

4 Likes

This was fixed by @pmusaraj :heart: a while back and I forgot to update here.

https://github.com/discourse/discourse/pull/6907/files

The shortcut should now work regardless of whether or not the input / textarea are focused.

Thanks for reporting the issue @TheBestPessimist :+1:

6 Likes