mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
search: Support multiple search pills creation.
This reverts part of b0d632577f.
The problem was that multiple queries were combined as a single
search pill. And since we create the pills then narrow / search,
we added a comma seperator between them for the typeahead lookups
as required by the logic in `input_pill.js`.
This however introduced a new bug where the search suggestions
were incorrect as the typeahead lookup table wasn't updated, so
every time an item from the type ahead was selected it updated
the input string with an invalid operator.
Thus to resolve the first problem, we follow a simpler approach
by extracting all operators from the search string using our
`Filter.parse` logic and next add the pills, one by one.
This commit is contained in:
@@ -1202,10 +1202,10 @@ run_test('multiple_operators_without_pills', () => {
|
||||
let suggestions = get_suggestions(base_query, query);
|
||||
let expected = [
|
||||
"is:private al",
|
||||
"is:private, is:alerted",
|
||||
"is:private, sender:alice@zulip.com",
|
||||
"is:private, pm-with:alice@zulip.com",
|
||||
"is:private, group-pm-with:alice@zulip.com",
|
||||
"is:private is:alerted",
|
||||
"is:private sender:alice@zulip.com",
|
||||
"is:private pm-with:alice@zulip.com",
|
||||
"is:private group-pm-with:alice@zulip.com",
|
||||
];
|
||||
assert.deepEqual(suggestions.strings, expected);
|
||||
|
||||
|
||||
@@ -21,7 +21,11 @@ exports.create_pills = function (pill_container) {
|
||||
};
|
||||
|
||||
exports.append_search_string = function (search_string, pill_widget) {
|
||||
pill_widget.appendValue(search_string);
|
||||
const operators = Filter.parse(search_string);
|
||||
for (const operator of operators) {
|
||||
const input = Filter.unparse([operator]);
|
||||
pill_widget.appendValue(input);
|
||||
}
|
||||
if (pill_widget.clear_text !== undefined) {
|
||||
pill_widget.clear_text();
|
||||
}
|
||||
|
||||
@@ -580,8 +580,7 @@ function make_attacher(base) {
|
||||
|
||||
function prepend_base(suggestion) {
|
||||
if (base && base.description.length > 0) {
|
||||
const sep = page_params.search_pills_enabled ? ", " : " ";
|
||||
suggestion.search_string = base.search_string + sep + suggestion.search_string;
|
||||
suggestion.search_string = base.search_string + " " + suggestion.search_string;
|
||||
suggestion.description = base.description + ", " + suggestion.description;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user