mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
minor: Check if typeahead query exists.
When a user entered an invalid character (whitespace or characters not present in a name), the cleaned-up array, and hence the query, would be empty which resulted in an error. Fixes #17542
This commit is contained in:
@@ -111,6 +111,22 @@ run_test("triage", () => {
|
||||
rest: [alice, alicia, steve, stephanie],
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
typeahead.triage(" ", names, (r) => r.name),
|
||||
{
|
||||
matches: [],
|
||||
rest: [alice, alicia, joan, jo, steve, stephanie],
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
typeahead.triage(";", names, (r) => r.name),
|
||||
{
|
||||
matches: [],
|
||||
rest: [alice, alicia, joan, jo, steve, stephanie],
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
run_test("sort_emojis th", () => {
|
||||
|
@@ -129,7 +129,7 @@ export function triage(query, objs, get_item) {
|
||||
const beginswithCaseSensitive = [];
|
||||
const beginswithCaseInsensitive = [];
|
||||
const noMatch = [];
|
||||
const lowerQuery = query.toLowerCase();
|
||||
const lowerQuery = query ? query.toLowerCase() : "";
|
||||
|
||||
for (const obj of objs) {
|
||||
const item = get_item(obj);
|
||||
|
Reference in New Issue
Block a user