jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.58k stars 4.85k forks source link

CTRL+F/CMD+F overrides browser's Find function with custom code #7380

Open JasonWeill opened 3 months ago

JasonWeill commented 3 months ago

Description

When the user presses CTRL+F or CMD+F, custom JupyterLab code for Find appears. This behavior differs from the classic notebook (https://github.com/jupyter/nbclassic/) which does not override these shortcut keys, and which instead allows the browser's built-in search bar to be displayed and used.

Expected behavior

By default, in Notebook 7, CTRL+F or CMD+F should cause the browser's default search user interface to display.

Context

This was spun off from #7041, originally filed by @jph00.

Jupyter Notebook should not override browsers' built-in keyboard shortcuts, wherever possible.

Virtual rendering may cause the browser's search box to search only a portion of the notebook; unrendered cells may not be made available to the browser.

jtpio commented 3 months ago

Jupyter Notebook should not override browsers' built-in keyboard shortcuts, wherever possible.

Yes this used to be the case before: https://github.com/jupyter/notebook/pull/6905#issuecomment-1582049295

Virtual rendering may cause the browser's search box to search only a portion of the notebook; unrendered cells may not be made available to the browser.

This was indeed changed in https://github.com/jupyter/notebook/pull/6905 because of the new implementation of the notebook.

ai-robert commented 1 month ago

@jtpio just to understand, does that mean the current behavior is intentional or is it just a side effect? and is there a way to turn it off? And perhaps most importantly, I'm designing a college course (ETA Fall 2025) that will have students run jupyter. To help them set up their environment I plan to give them either a pip requirements file or an anaconda configuration to help them set up what they need for the course. Would there be a way using one of those two methods to make the browser search the default search behavior upon setup, so I don't need to ask the students to go into settings to customize that?

jtpio commented 1 month ago

@ai-robert yes this is intentional because of how the notebook component works in JupyterLab / Jupyter Notebook. See the comment above:

This was indeed changed in https://github.com/jupyter/notebook/pull/6905 because of the new implementation of the notebook.

To turn it off, you should be able to provide a custom settings file to disable the related keyboard shortcut. Or disable the notebook windowing mode (default is full) so all the cells are displayed on the page, which should help search on the whole page with the built-in browser search.

See https://jupyter-notebook.readthedocs.io/en/stable/notebook.html#searching for more information. Happy to improve docs on this if you feel like opening a PR to make some edits please feel free, thanks!

dreampuf commented 1 week ago

Can we have a simple way to disable it? I really doubt searching is working properly. It can't find what I need in most cases. The browser's search works well for both code and output.

image
jtpio commented 1 week ago

@dreampuf were you able to try the suggestion from the above comment?

To turn it off, you should be able to provide a custom settings file to disable the related keyboard shortcut. Or disable the notebook windowing mode (default is full) so all the cells are displayed on the page, which should help search on the whole page with the built-in browser search.

Or are you suggesting there should be a more visible and explicit setting (or menu item) to disable the built-in search?

krassowski commented 1 week ago

I really doubt searching is working properly. It can't find what I need in most cases

Can you open an issue with reproducible example? If you refer to searching in outputs, you currently need to click on the filters icon and select "Search Cell Outputs".

image

I believe there is a broad agreement that this should be enabled by default:

krassowski commented 1 week ago

explicit setting (or menu item) to disable the built-in search

This was also brought up in https://github.com/jupyterlab/jupyterlab/discussions/16741 2 days ago. I think there should be an escape hatch for users to disable the built-in search, while also believing that there is a need to improve the defaults (as above) so that users do not need/want to disable it ;)

dreampuf commented 6 days ago

@jtpio @krassowski, I don't know the contexts in full window mode, so I did some searching on the keywords. https://blog.jupyter.org/jupyterlab-4-2-and-notebook-7-2-are-available-b5e6b3c753de

If the full mode is the way to improve the performance, I'm ok with having a customized search box. However, the downside would be the different behavior compared to browsers. Explicit options to enable output search would help, and if its default could align the behavior with the browser's, it would be even better.