Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

typeahead: Refactor switch statements to avoid fallthrough.

evykassirer40b4db332308
diff --git a/web/third/bootstrap-typeahead/typeahead.js b/web/third/bootstrap-typeahead/typeahead.js
index 6990f7f1a6f..cd967bb6581 100644
--- a/web/third/bootstrap-typeahead/typeahead.js
+++ b/web/third/bootstrap-typeahead/typeahead.js
@@ -460,6 +460,9 @@ import {get_string_diff} from "../../src/util";
if (!this.options.tabIsEnter) {
return;
}
+ e.preventDefault();
+ break;
+
case 13: // enter
case 27: // escape
e.preventDefault();
@@ -521,6 +524,12 @@ import {get_string_diff} from "../../src/util";
if (!this.options.tabIsEnter) {
return;
}
+ if (!this.shown) {
+ return;
+ }
+ this.select(e);
+ break;
+
case 13: // enter
if (!this.shown) {
return;
@@ -538,14 +547,15 @@ import {get_string_diff} from "../../src/util";
}
break;
- // to stop typeahead from showing up momentarily
- // when shift + tabbing to the topic field
- case 16: // shift
- if (e.currentTarget.id === "stream_message_recipient_topic") {
+ default:
+ // to stop typeahead from showing up momentarily
+ // when shift (keycode 16) + tabbing to the topic field
+ if (
+ pseudo_keycode === 16 &&
+ e.currentTarget.id === "stream_message_recipient_topic"
+ ) {
return;
}
-
- default:
var hideOnEmpty = false;
// backspace
if (