Skip to content

Commit 1a45660

Browse files
author
minjk-bl
committed
Fix esc shortcut to close popups: checking priority as [data selector -> inner popup -> popup]
1 parent 3176f07 commit 1a45660

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

js/com/com_Event.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,23 @@ define([], function() {
207207
that.keyManager.keyCheck.shiftKey = false;
208208
}
209209
if (evt.keyCode == that.keyManager.keyCode.escKey) {
210-
// close popup on esc
211-
$('#vp_wrapper').trigger({
212-
type: 'close_option_page',
213-
component: that.mainFrame.focusedPage
214-
});
210+
// check if there is visible data selector : DataSelector
211+
if ($('.vp-dataselector-base:visible').length > 0) {
212+
// close data selector
213+
$('.vp-dataselector-base:visible').remove();
214+
}
215+
// check if there is visible inner popup
216+
else if ($('.vp-popup-frame > .vp-inner-popup-box:visible').length > 0) {
217+
// close inner popup on esc
218+
console.log('close inner popup from this component', that.mainFrame.focusedPage);
219+
that.mainFrame.focusedPage && that.mainFrame.focusedPage.closeInnerPopup();
220+
} else {
221+
// close popup on esc
222+
$('#vp_wrapper').trigger({
223+
type: 'close_option_page',
224+
component: that.mainFrame.focusedPage
225+
});
226+
}
215227
}
216228
if (evt.keyCode == that.keyManager.keyCode.enter) {
217229
// blur on enter

js/com/component/PopupComponent.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,13 @@ define([
403403
});
404404
// Close event for inner popup
405405
$(this.wrapSelector('.vp-inner-popup-close')).on('click', function(evt) {
406-
that.handleInnerCancel();
407406
that.closeInnerPopup();
408407
});
409408
// Click button event for inner popup
410409
$(this.wrapSelector('.vp-inner-popup-button')).on('click', function(evt) {
411410
let btnType = $(this).data('type');
412411
switch(btnType) {
413412
case 'cancel':
414-
that.handleInnerCancel();
415413
that.closeInnerPopup();
416414
break;
417415
case 'ok':
@@ -480,7 +478,7 @@ define([
480478
template() {
481479
this.$pageDom = $(popupComponentHtml);
482480
// set title
483-
this.$pageDom.find('.vp-popup-title').text(this.state.config.name);
481+
this.$pageDom.find('.vp-popup-title').text(this.name);
484482
// set body
485483
this.$pageDom.find('.vp-popup-content').html(this.templateForBody());
486484
return this.$pageDom;
@@ -848,13 +846,16 @@ define([
848846
$(this.wrapSelector('.vp-inner-popup-box')).show();
849847

850848
// focus on first input
851-
$(this.wrapSelector('.vp-inner-popup-box input[type=text]:not(:disabled):visible:first')).focus();
849+
$(this.wrapSelector('.vp-inner-popup-box input:not(:disabled):visible:first')).focus();
850+
// disable Jupyter key
851+
com_interface.disableOtherShortcut();
852852
}
853853

854854
/**
855855
* Close inner popup box
856856
*/
857857
closeInnerPopup() {
858+
this.handleInnerCancel();
858859
$(this.wrapSelector('.vp-inner-popup-box')).hide();
859860
}
860861

0 commit comments

Comments
 (0)