Defect #41096
closed"##" syntax auto complete does not work
0%
Description
When triggered with a text starting with ##
, like ##a
, the search query becomes #a
.
The controller receives #a
but returns nothing because there are no issues that match the query.
Below is a part of Rails log when the input is ##a
:
Started GET "/issues/auto_complete?project_id=ecookbook&q=%23ab" for 192.168.65.1 at 2024-08-06 01:26:32 +0000 Processing by AutoCompletesController#issues as */* Parameters: {"project_id"=>"ecookbook", "q"=>"#a"} (snip) Issue Load (0.4ms) SELECT "issues".* FROM "issues" (snip) AND (issues.subject LIKE '%#a%' ESCAPE '\') ORDER BY "issues"."id" DESC LIMIT ? [["project_id", 1], ["LIMIT", 10]]
I confirmed that this problem occurs in at least Redmine v5.1 and trunk.
Also, due to this problem, the system test 'test_inline_autocomplete_for_issues_with_double_hash_keep_syntax' is currently failing.
Capybara starting Puma... * Version 6.4.2, codename: The Eagle of Durango * Min threads: 0, max threads: 4 * Listening on http://127.0.0.1:38479 ...........[Screenshot Image]: /redmine/tmp/screenshots/failures_test_inline_autocomplete_for_issues_with_double_hash_keep_syntax.png F Failure: InlineAutocompleteSystemTest#test_inline_autocomplete_for_issues_with_double_hash_keep_syntax [test/system/inline_autocomplete_test.rb:53]: Expected false to be truthy. ...This problem appears to be related to the following issues:
Files
Updated by Katsuya HIDAKA 5 months ago
- File 0001-Fix-that-syntax-auto-complete-does-not-work.patch 0001-Fix-that-syntax-auto-complete-does-not-work.patch added
This patch removes the leading #
from the search query so that the controller receives the correct search query.
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index fcd9aed54..47be33567 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1164,6 +1164,11 @@ function inlineAutoComplete(element) {
if (event.target.type === 'text' && $(element).attr('autocomplete') != 'off') {
$(element).attr('autocomplete', 'off');
}
+ // When triggered with a text starting with ##, like ##a, the search query will be #a.
+ // To avoid this, remove the first # from the search query.
+ if (text) {
+ text = text.replace(/^#/, '');
+ }
remoteSearch(getDataSource('issues') + encodeURIComponent(text), function (issues) {
return cb(issues);
});
I confirmed that the ##
syntax auto complete works correctly in both Redmine v5.1 and the trunk, and that all unit tests and system tests pass.
I also tried adding a new definition for triggering the ##
syntax in Tribute. However, I gave up on this approach because I realized that the current implementation of Tribute always references the definition for the #
syntax trigger.
Updated by Massimo Rossello 4 months ago
I think this should be backported to 5.0.x as well