typeahead: Refactor switch statements to avoid fallthrough.

This commit is contained in:
evykassirer
2024-03-01 14:33:11 -08:00
committed by Tim Abbott
parent ff1f62bc56
commit 40b4db3323

View File

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