Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fullscreen feature with command alt f #16308

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

dhysdrn
Copy link

@dhysdrn dhysdrn commented May 8, 2024

References:

Fixes #8710 - Add fullscreen option to JupyterLab
Adding the base fullscreen mode functionality in preparation for fullscreen mode expansion to allow individual widgets to enter fullscreen mode for presentation purposes per the requests in PR #10676.

Code Changes:

jupyterlab/packages/application-extension/src/index.tsx
Added Lines 113-114 - Export the toggleFullscreenMode component.
Added Lines 438-454 - The toggleFullscreenMode command component
Added Line 544 - Register the new command as a CommandIDs entry in the palette
jupyterlab/packages/application-extension/schema/commands.json
Added Lines 293-296 - Include keyboard shortcut of Alt + F
Added Lines 50-54 - Include the fullscreen option in the top bar menu
jupyterlab/packages/application/shell.d.ts
Added Lines 282-287 Created the entry to get/set the fullscreenMode css value to the shell div (preparation for individual fullscreen widgets)

User-Facing Changes:

Provides a menu option to enter fullscreen mode and uses Alt + F as the shortcut key to toggle into and out of fullscreen mode.
no-fullscreen-menu
fullscreen-menu

F11 remains disabled as a means to enter fullscreen mode to maintain current production JupyterLab behavior.

If entering fullscreen using the Alt + F shortcut or button in the view > Fullscreen Mode menu, users can exit with the view > Fullscreen Mode menu option, Alt + F, ESC key, or F11 key, and JupyterLab maintains fullscreen synchronization of the menu item, check box, and CSS styling.
fullscreen-menu-checked

Backwards-incompatible Changes:

None

Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

Copy link

welcome bot commented May 8, 2024

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@Rob-P-Smith
Copy link
Contributor

Rob-P-Smith commented May 8, 2024

@meeseeksdev tag enhancement

bot please update snapshots

Copy link
Contributor

github-actions bot commented May 8, 2024

Documentation snapshots updated.

Copy link
Contributor

github-actions bot commented May 8, 2024

Galata snapshots updated.

@krassowski krassowski added this to the 4.3.0 milestone May 9, 2024
@Rob-P-Smith
Copy link
Contributor

@krassowski We've adjusted the code to align more with the existing codebase and cleaned up the uncaught error issue that previously failed "jplm run eslint:typed".

If this is acceptable, we'd like to close this and work on full-screening individual elements as a separate issue next, e.g. terminal/notebook/widgets etc as requested in the previous PR that attempted to solve issue #8710 here:
#10676

bot please update snapshots

Copy link
Contributor

Documentation snapshots updated.

Copy link
Contributor

Galata snapshots updated.

@krassowski
Copy link
Member

Just as FYI, you do not need to write down the code changes by file and line range in the PR description (these these quickly get outdated). What I would recommend is to focus on listing major API changes if there are any, e.g. that fullScreenMode was added to LabShell.

Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a strong opinion on this, but I think it is fine to start with.
Before this can be merged here is a few suggestions.

packages/application-extension/src/index.tsx Outdated Show resolved Hide resolved
/**
* Toggle the fullscreen mode based on user inputs
*/
setFullscreenMode(): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this method? Could it be handled in the setter of fullscreenMode property instead to minimize the API surface?

* `jp-mod-fullscreenMode` CSS class.
*/
get fullscreenMode(): boolean {
return this.hasClass('jp-mod-fullscreenMode');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should store state which can be modified by the JS API by using a CSS class - this can lead to inconsistent state if an extension or JS in outputs of user executed code manipulate the fullscreen state (for example rise extension for presenting slides could do that).

I would prefer if the getter returned the state derived from the browser API like fullscreenElement. That said, I am not even sure if we need a getter/setter here - if we are not setting the CSS class, then we could get away without extending the public API of LabShell at all, which will make merging this PR much easier.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We made the changes and removed the getter/setter and directly queried the fullscreenElement value, we also reverted toggle sidebar widget to its original code. Thank you! (:

@dhysdrn
Copy link
Author

dhysdrn commented May 20, 2024

@krassowski it looks like we're failing some tests and unsure what we need to do to fix it, could you help us with this?

@krassowski
Copy link
Member

Some of the failing tests are just flaky, I can restart these. One screenshot test appears to need updating:

[jupyterlab] › test/jupyterlab/menus.test.ts:30:9 › General Tests › Open menu item View>Appearance

bot please update galata snapshots (we may need to revert some spurious updates afterwards)

Copy link
Contributor

Galata snapshots updated.

@dhysdrn
Copy link
Author

dhysdrn commented May 26, 2024

bot please update galata snapshots

Copy link
Contributor

Documentation snapshots updated.

Copy link
Contributor

Galata snapshots updated.

@dhysdrn
Copy link
Author

dhysdrn commented May 27, 2024

@krassowski i think we made all the right changes, could you help us with this?

/**
* Toggle the fullscreen mode based on user inputs
*/
toggleFullscreenMode(): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I ask for one more thing - to move this method into a function in packages/application-extension/src/index.tsx?

The rationale is a follows: once we add something to LabShell class , any attempt to change it will be potentially breaking for an extension. Since there is further expansion of the fullscreen capabilities requested (to cover making individual elements take the full screen) enhancements, I think it is likely that the implementation may change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krassowski we’ve removed the method and added it to packages/application-extension/src/index.tsx, let us know if it looks good

@dhysdrn
Copy link
Author

dhysdrn commented Jun 6, 2024

@krassowski Hey, just checking in 👋🏻 We would love to close this out and get it merged. Do let us know if we’re good or if we need anymore changes (:

Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing:

  • GNOME Web (webkit): works ok
  • Chrome: works ok
  • Firefox: works when clicking on the menu, does not work with Alt + F - it throws:
Request for fullscreen was denied because Element.requestFullscreen() was not called from inside a short running user-generated event handler. [index.tsx:458:37](webpack://jupyterlab/packages/application-extension/src/index.tsx)
Failed to enter fullscreen mode. TypeError: Fullscreen request denied
    execute index.tsx:458
    execute index.es6.js:365
    _executeKeyBinding index.es6.js:569
    processKeydownEvent index.es6.js:473
    evtKeydown lab.ts:217

In both Chrome and Firefox, entering full screen manually with F11 and then invoking the application:toggle-fullscreen-mode command forces the user to escape the full screen twice. This is odd.

@@ -47,6 +47,11 @@
"keys": [""],
"selector": "body"
},
{
"command": "application:toggle-fullscreen-mode",
"keys": ["Alt F"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alt + F is used by browsers to:

  • open File menu (Firefox)
  • open three dots menu (Chrome/Edge)

It may or may not be ok to override these. We can discuss this on JupyterLab call on Wednesday. Would it be also ok to just use F11 which is typically default for full screen? This way the contribution of this PR is:

  • it adds a menu entry
  • it allows user to change the shortcut
  • it does not force a no-standard shortcut which is normally used for something else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add full screen option to JupyterLab
3 participants