Add maybe_show_keyboard_shortcuts().

This prevents some strange UI experiences and some blueslip
errors by not opening keyboard help when other overlays or
popovers are open.
This commit is contained in:
Steve Howell
2017-06-15 10:11:17 -04:00
parent 1d47a7b505
commit d2b710b307
3 changed files with 12 additions and 2 deletions

View File

@@ -200,7 +200,7 @@ function stubbing(func_name_to_stub, test_function) {
assert_mapping('n', 'subs.new_stream_clicked');
overlays.streams_open = return_false;
assert_mapping('?', 'ui.show_info_overlay');
assert_mapping('?', 'ui.maybe_show_keyboard_shortcuts');
assert_mapping('/', 'search.initiate_search');
assert_mapping('q', 'activity.initiate_search');
assert_mapping('w', 'stream_list.initiate_search');

View File

@@ -564,7 +564,7 @@ exports.process_hotkey = function (e, hotkey) {
gear_menu.open();
return true;
case 'show_shortcuts': // Show keyboard shortcuts page
ui.show_info_overlay("keyboard-shortcuts");
ui.maybe_show_keyboard_shortcuts();
return true;
case 'stream_cycle_backward':
navigate.cycle_stream('backward');

View File

@@ -156,6 +156,16 @@ exports.show_info_overlay = function (target) {
}
};
exports.maybe_show_keyboard_shortcuts = function () {
if (overlays.is_active()) {
return;
}
if (popovers.any_active()) {
return;
}
ui.show_info_overlay("keyboard-shortcuts");
};
var loading_more_messages_indicator_showing = false;
exports.show_loading_more_messages_indicator = function () {
if (! loading_more_messages_indicator_showing) {