Skip to content

Commit 6d7fd5c

Browse files
authored
Merge pull request #3282 from parente/fix-3276-click-modifiers
Fix clicking with modifiers, page title updates
2 parents 3de5e50 + 386b3a2 commit 6d7fd5c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

notebook/static/tree/js/notebooklist.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ define([
365365
breadcrumb.empty();
366366
var list_item = $('<li/>');
367367
var root = $('<li/>').append('<a href="/tree"><i class="fa fa-folder"></i></a>').click(function(e) {
368+
// Allow the default browser action when the user holds a modifier (e.g., Ctrl-Click)
369+
if(e.altKey || e.metaKey || e.shiftKey) {
370+
return true;
371+
}
368372
var path = '';
369373
window.history.pushState({
370374
path: path
@@ -383,6 +387,10 @@ define([
383387
utils.encode_uri_components(path)
384388
);
385389
var crumb = $('<li/>').append('<a href="' + url + '">' + path_part + '</a>').click(function(e) {
390+
// Allow the default browser action when the user holds a modifier (e.g., Ctrl-Click)
391+
if(e.altKey || e.metaKey || e.shiftKey) {
392+
return true;
393+
}
386394
window.history.pushState({
387395
path: path
388396
}, path, url);
@@ -404,6 +412,10 @@ define([
404412
$('body').attr('data-notebook-path', path);
405413
// Update the file tree list without reloading the page
406414
this.load_list();
415+
// Update the page title so the browser tab reflects it
416+
// Match how the title appears with a trailing slash or
417+
// "Home" if the page loads from the server.
418+
$('title').text(path ? path+'/' : i18n.msg._("Home"));
407419
};
408420

409421
/**
@@ -810,8 +822,12 @@ define([
810822
link.attr('target', IPython._target);
811823
} else {
812824
// Replace with a click handler that will use the History API to
813-
// push a new route without reloading the page
825+
// push a new route without reloading the page if the click is
826+
// not modified (e.g., Ctrl-Click)
814827
link.click(function (e) {
828+
if(e.altKey || e.metaKey || e.shiftKey) {
829+
return true;
830+
}
815831
window.history.pushState({
816832
path: model.path
817833
}, model.path, utils.url_path_join(

0 commit comments

Comments
 (0)