FIX: topic title in search contains data-topic-id (#9435)

FIX: topic title in search contains data-topic-id (#9435)

Data topic id is required by the discourse-encrypt plugin.

Related to https://github.com/discourse/discourse-encrypt/pull/12

diff --git a/app/assets/javascripts/discourse/widgets/search-menu-results.js b/app/assets/javascripts/discourse/widgets/search-menu-results.js
index 6d46819..cdb4869 100644
--- a/app/assets/javascripts/discourse/widgets/search-menu-results.js
+++ b/app/assets/javascripts/discourse/widgets/search-menu-results.js
@@ -145,7 +145,11 @@ createSearchResult({
 
     const firstLine = [
       this.attach("topic-status", { topic, disableActions: true }),
-      h("span.topic-title", new Highlighted(topic.fancyTitle, term))
+      h(
+        "span.topic-title",
+        { attributes: { "data-topic-id": topic.id } },
+        new Highlighted(topic.fancyTitle, term)
+      )
     ];
 
     const secondLine = [
diff --git a/test/javascripts/acceptance/search-test.js b/test/javascripts/acceptance/search-test.js
index 62d4323..018e3a0 100644
--- a/test/javascripts/acceptance/search-test.js
+++ b/test/javascripts/acceptance/search-test.js
@@ -28,6 +28,10 @@ QUnit.test("search", async assert => {
   await fillIn("#search-term", "dev");
   await keyEvent("#search-term", "keyup", 16);
   assert.ok(exists(".search-menu .results ul li"), "it shows results");
+  assert.ok(
+    exists(".search-menu .results ul li .topic-title[data-topic-id]"),
+    "topic has data-topic-id"
+  );
 
   await click(".show-help");
 

GitHub sha: 5a60a423

This commit appears in #9435 which was approved by udan11. It was merged by lis2.