autocomplete: fix autocomplete triggering after blank space.
This commit is contained in:
@@ -98,11 +98,6 @@ Autocomplete.initialize_tag_autocomplete = function() {
|
|||||||
var metatag = query.metatag;
|
var metatag = query.metatag;
|
||||||
var term = query.term;
|
var term = query.term;
|
||||||
|
|
||||||
if (!metatag && !term) {
|
|
||||||
this.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (metatag) {
|
switch (metatag) {
|
||||||
case "order":
|
case "order":
|
||||||
case "status":
|
case "status":
|
||||||
@@ -244,6 +239,11 @@ Autocomplete.initialize_wiki_autocomplete = function($fields) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Autocomplete.normal_source = function(term, resp) {
|
Autocomplete.normal_source = function(term, resp) {
|
||||||
|
if (term === "") {
|
||||||
|
resp([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
url: "/tags/autocomplete.json",
|
url: "/tags/autocomplete.json",
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class AutocompleteTest < ApplicationSystemTestCase
|
|||||||
|
|
||||||
def assert_autocomplete_equals(expected_results, text, id:)
|
def assert_autocomplete_equals(expected_results, text, id:)
|
||||||
autocomplete(id, text)
|
autocomplete(id, text)
|
||||||
|
sleep 1 if expected_results.empty?
|
||||||
|
|
||||||
assert_selector 'ul.ui-autocomplete li', count: expected_results.size
|
assert_selector 'ul.ui-autocomplete li', count: expected_results.size
|
||||||
expected_results.each do |result|
|
expected_results.each do |result|
|
||||||
@@ -102,6 +103,11 @@ class AutocompleteTest < ApplicationSystemTestCase
|
|||||||
assert_search_autocomplete_equals([], "one two")
|
assert_search_autocomplete_equals([], "one two")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "not complete tags after a space" do
|
||||||
|
create(:tag, name: "bkub", post_count: 42)
|
||||||
|
assert_search_autocomplete_equals([], "bkub ")
|
||||||
|
end
|
||||||
|
|
||||||
should "correct invalid operator combinations" do
|
should "correct invalid operator combinations" do
|
||||||
create(:tag, name: "bkub", post_count: 42)
|
create(:tag, name: "bkub", post_count: 42)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user