diff --git a/frontend_tests/node_tests/search_suggestion.js b/frontend_tests/node_tests/search_suggestion.js index 978e0d8140..9ed73908e1 100644 --- a/frontend_tests/node_tests/search_suggestion.js +++ b/frontend_tests/node_tests/search_suggestion.js @@ -780,7 +780,6 @@ run_test('contains_suggestions', () => { var query = 'has:'; var suggestions = search.get_suggestions(query); var expected = [ - 'has:', 'has:link', 'has:image', 'has:attachment', @@ -790,7 +789,6 @@ run_test('contains_suggestions', () => { query = 'has:im'; suggestions = search.get_suggestions(query); expected = [ - 'has:im', 'has:image', ]; assert.deepEqual(suggestions.strings, expected); @@ -798,7 +796,6 @@ run_test('contains_suggestions', () => { query = '-has:im'; suggestions = search.get_suggestions(query); expected = [ - '-has:im', '-has:image', ]; assert.deepEqual(suggestions.strings, expected); @@ -814,7 +811,6 @@ run_test('contains_suggestions', () => { query = 'stream:Denmark is:alerted has:lin'; suggestions = search.get_suggestions(query); expected = [ - 'stream:Denmark is:alerted has:lin', 'stream:Denmark is:alerted has:link', 'stream:Denmark is:alerted', 'stream:Denmark', diff --git a/static/js/search_suggestion.js b/static/js/search_suggestion.js index 049460e4ed..bdda27fa05 100644 --- a/static/js/search_suggestion.js +++ b/static/js/search_suggestion.js @@ -538,7 +538,10 @@ exports.get_suggestions = function (query) { } // Display the default first - if (last.operator !== '') { + // `has` operator works only on predefined categories. Default suggestion + // is not displayed in that case. e.g. `messages with one or more abc` as + // a suggestion for `has:abc`does not make sense. + if (last.operator !== '' && last.operator !== 'has') { suggestion = get_default_suggestion(operators); result = [suggestion]; }