From c76dea3ab32a43ed7704f770d98fd33dc1d357bf Mon Sep 17 00:00:00 2001 From: Taka Date: Thu, 29 Nov 2018 05:04:45 +0000 Subject: [PATCH] Handle hotkeys if a dialog is up, or a dropdown is showing. --- vasl_templates/webapp/static/main.js | 8 ++++++++ vasl_templates/webapp/static/utils.js | 1 + 2 files changed, 9 insertions(+) diff --git a/vasl_templates/webapp/static/main.js b/vasl_templates/webapp/static/main.js index e65e793..4b98b74 100644 --- a/vasl_templates/webapp/static/main.js +++ b/vasl_templates/webapp/static/main.js @@ -474,6 +474,14 @@ function init_hotkeys() jQuery.hotkeys.options.filterTextInputs = false ; function set_focus_to( tab, $ctrl ) { + if ( $(".ui-widget-overlay").length > 0 ) + return ; // nb: a dialog is up + if ( $( ".select2-dropdown" ).length > 0 ) { + // FUDGE! A select2 dropdown is showing, but which one? We just close them all :-/ + $( ".app-select2" ).each( function() { + $(this).select2( "close" ) ; + } ) ; + } var curr_tab = $("#tabs .ui-tabs-active a").attr( "href" ) ; if ( curr_tab !== tab ) $("#tabs .ui-tabs-nav a[href='"+tab+"']").trigger( "click" ) ; diff --git a/vasl_templates/webapp/static/utils.js b/vasl_templates/webapp/static/utils.js index fba8976..9d1d3ba 100644 --- a/vasl_templates/webapp/static/utils.js +++ b/vasl_templates/webapp/static/utils.js @@ -287,6 +287,7 @@ function init_select2( $sel, width, search_box, format ) } $sel = $sel.select2( args ) ; $sel.data( "select2" ).$container.attr( "name", name ) ; + $sel.addClass( "app-select2" ) ; return $sel ; }