Skip to content
This repository

Intercept <esc> avoid closing websocket on Firefox #1032

Closed
wants to merge 1 commit into from

4 participants

Matthias Bussonnier Fernando Perez Thomas Kluyver Min RK
Matthias Bussonnier
Collaborator

closes #1031

To rephrase what on #1031, default action of <esc> on Firefox is to stop the page loading, and it also closes the websocket conexion.
so I intercept it a notebook level and call event.preventDefault()

Thomas Kluyver takluyver commented on the diff November 23, 2011
IPython/frontend/html/notebook/static/js/notebook.js
@@ -57,6 +57,11 @@ var IPython = (function (IPython) {
57 57
         $(document).keydown(function (event) {
58 58
             // console.log(event);
59 59
             if (that.read_only) return;
3
Thomas Kluyver Collaborator

Do we need to catch it before this line? I don't know if read_only means passive observer (using websockets) or static view (not using websockets).

Matthias Bussonnier Collaborator
Carreau added a note November 23, 2011

In my test, it is static-view, and the websocket doen't close when pressing <esc> even without this patch when read-only, so it doesn't really matters...

IMHO, I prefer to have it after if(that.read_only) because it kind of separate read-only logic from key handeling logic.

Min RK Owner
minrk added a note November 23, 2011

As it is currently defined, read-only mode establishes no websocket connections.

That's part of what read-only means - no connections to the kernel (all websocket connections are for kernel communication).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Min RK minrk commented on the diff November 23, 2011
IPython/frontend/html/notebook/static/js/notebook.js
@@ -57,6 +57,11 @@ var IPython = (function (IPython) {
57 57
         $(document).keydown(function (event) {
58 58
             // console.log(event);
59 59
             if (that.read_only) return;
  60
+            if (event.which === 27) {
  61
+                // Intercept escape at highest level to avoid closing 
  62
+                // websocket connexionwith firefox
1
Min RK Owner
minrk added a note November 23, 2011

typo 'connexionwith' -> 'connection with'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Fernando Perez fperez closed this pull request from a commit November 23, 2011
Matthias Bussonnier Intercept <esc> avoid closing websocket on Firefox
Closes #1031; closes #1032 (rebased and fixed tiny typo)
a329ff0
Fernando Perez fperez closed this in a329ff0 November 23, 2011
Fernando Perez
Owner

Thanks! I confirmed that it fixes the problem on ffox and fixed the tiny typo. Merged (with a rebase to avoid recursive merge) and pushed. Thanks everyone for the review too...

Fernando Perez fperez referenced this pull request from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 23, 2011
Matthias Bussonnier Intercept <esc> avoid closing websocket on Firefox
	closes #1031
8900def
This page is out of date. Refresh to see the latest.
5  IPython/frontend/html/notebook/static/js/notebook.js
@@ -57,6 +57,11 @@ var IPython = (function (IPython) {
57 57
         $(document).keydown(function (event) {
58 58
             // console.log(event);
59 59
             if (that.read_only) return;
  60
+            if (event.which === 27) {
  61
+                // Intercept escape at highest level to avoid closing 
  62
+                // websocket connexionwith firefox
  63
+                event.preventDefault();
  64
+            }
60 65
             if (event.which === 38) {
61 66
                 var cell = that.selected_cell();
62 67
                 if (cell.at_top()) {
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.