]> source.dussan.org Git - redmine.git/commitdiff
Keep existing @##@ syntax when triggering an issue from the inline autocomplete ...
authorMarius Balteanu <marius.balteanu@zitec.com>
Sat, 11 Nov 2023 07:10:51 +0000 (07:10 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Sat, 11 Nov 2023 07:10:51 +0000 (07:10 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@22419 e93f8b46-1217-0410-a6f0-8f06a7374b81

public/javascripts/application.js
test/system/inline_autocomplete_test.rb

index a183a2777b94c993ce18434db2c0fb349e09dccf..d39475d46d3fd03ca2ebe2c3dc31276d63a1dfd3 100644 (file)
@@ -1172,7 +1172,12 @@ function inlineAutoComplete(element) {
           fillAttr: 'label',
           requireLeadingSpace: true,
           selectTemplate: function (issue) {
-            return '#' + issue.original.id;
+            let leadingHash = "#"
+            // keep ## syntax which is a valid issue syntax to show issue with title.
+            if (this.currentMentionTextSnapshot.charAt(0) === "#") {
+              leadingHash = "##"
+            }
+            return leadingHash + issue.original.id;
           },
           menuItemTemplate: function (issue) {
             return sanitizeHTML(issue.original.label);
index 16a8ebdce7058bd452c8c36bd0b70eb6e0a51378..25d86fd6bc1c8a58bbc267e2ce6e9801c71b78ca 100644 (file)
@@ -43,6 +43,22 @@ class InlineAutocompleteSystemTest < ApplicationSystemTestCase
     assert_equal '#12 ', find('#issue_description').value
   end
 
+  def test_inline_autocomplete_for_issues_with_double_hash_keep_syntax
+    log_user('admin', 'admin')
+    visit 'projects/ecookbook/issues/new'
+
+    fill_in 'Description', :with => '##Closed'
+
+    within('.tribute-container') do
+      assert page.has_text? 'Bug #12: Closed issue on a locked version'
+      assert page.has_text? 'Bug #11: Closed issue on a closed version'
+
+      first('li').click
+    end
+
+    assert_equal '##12 ', find('#issue_description').value
+  end
+
   def test_inline_autocomplete_filters_autocomplete_items
     log_user('jsmith', 'jsmith')
     visit 'issues/new'