Skip to content

Commit 5961997

Browse files
ednut15takluyver
authored andcommitted
Fixed issue #3983: Return focus to Not trusted notification when modal is closed (#4745)
* Resolvedg merge conflicts * removed strig comparison * #3983 Removed unnecessary lines * Add if statement to focus button
1 parent 3e2ee04 commit 5961997

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

notebook/static/base/js/dialog.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ define(['jquery',
131131
options.keyboard_manager.enable();
132132
options.keyboard_manager.command_mode();
133133
}
134+
if (options.focus_button) {
135+
$(options.focus_button).focus();
136+
}
134137
});
135138

136139
if (options.keyboard_manager) {

notebook/static/notebook/js/notebook.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2973,7 +2973,7 @@ define([
29732973
/**
29742974
* Explicitly trust the output of this notebook.
29752975
*/
2976-
Notebook.prototype.trust_notebook = function () {
2976+
Notebook.prototype.trust_notebook = function (from_notification) {
29772977
var body = $("<div>").append($("<p>")
29782978
.text(i18n.msg._("A trusted Jupyter notebook may execute hidden malicious code when you open it. " +
29792979
"Selecting trust will immediately reload this notebook in a trusted state. " +
@@ -2989,6 +2989,7 @@ define([
29892989
keyboard_manager: this.keyboard_manager,
29902990
title: i18n.msg._("Trust this notebook?"),
29912991
body: body,
2992+
focus_button: from_notification,
29922993

29932994
buttons: {
29942995
Cancel : {},

notebook/static/notebook/js/notificationarea.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ define([
402402
$(tnw.selector).css('cursor', 'help');
403403
} else {
404404
tnw.set_message(i18n.msg._("Not Trusted"), undefined, function() {
405-
that.notebook.trust_notebook();
405+
that.notebook.trust_notebook("#notification_trusted");
406406
return false;
407407
}, {'title':'Javascript disabled for notebook display'});
408408
$(tnw.selector).attr('role', 'button');

0 commit comments

Comments
 (0)