Tienson Qin před 1 rokem
rodič
revize
9efcaf41c1

+ 6 - 7
e2e-tests/fs.spec.ts

@@ -37,7 +37,7 @@ test('create file on disk then delete', async ({ page, block, graphDir }) => {
     const results = await searchPage(page, pageTitle);
     const firstResultRow = await results[0].innerText()
     expect(firstResultRow).toContain(pageTitle);
-    expect(firstResultRow).not.toContain("New");
+    expect(firstResultRow).not.toContain("Create");
     await closeSearchBox(page);
   }
 
@@ -51,7 +51,7 @@ test('create file on disk then delete', async ({ page, block, graphDir }) => {
     // Test that the page is deleted
     const results = await searchPage(page, pageTitle);
     const firstResultRow = await results[0].innerText()
-    expect(firstResultRow).toContain("New");
+    expect(firstResultRow).toContain("Create");
     await closeSearchBox(page);
   }
 });
@@ -62,7 +62,7 @@ test("Rename file on disk", async ({ page, block, graphDir }) => {
 
   const testCases = [
     // Normal -> NameSpace
-    {pageTitle: "User:John", fileName: "User%3AJohn", 
+    {pageTitle: "User:John", fileName: "User%3AJohn",
     newPageTitle: "User/John", newFileName: "User___John"},
     // NameSpace -> Normal
     {pageTitle: "#/%23", fileName: "#___%2523",
@@ -87,7 +87,7 @@ test("Rename file on disk", async ({ page, block, graphDir }) => {
     const results = await searchPage(page, pageTitle);
     const firstResultRow = await results[0].innerText()
     expect(firstResultRow).toContain(pageTitle);
-    expect(firstResultRow).not.toContain("New");
+    expect(firstResultRow).not.toContain("Create");
     await closeSearchBox(page);
   }
 
@@ -104,7 +104,7 @@ test("Rename file on disk", async ({ page, block, graphDir }) => {
     const firstResultRow = await results[0].innerText()
     expect(firstResultRow).toContain(newPageTitle);
     expect(firstResultRow).not.toContain(pageTitle);
-    expect(firstResultRow).not.toContain("New");
+    expect(firstResultRow).not.toContain("Create");
     await closeSearchBox(page);
   }
 })
@@ -112,7 +112,6 @@ test("Rename file on disk", async ({ page, block, graphDir }) => {
 test('special page names', async ({ page, block, graphDir }) => {
   const testCases = [
     {pageTitle: "User:John", fileName: "User%3AJohn"},
-    // FIXME: Logseq can't creat page starting with "#" in search panel
     {pageTitle: "_#%ff", fileName: "_%23%25ff"},
     {pageTitle: "_#%23", fileName: "_%23%2523"},
     {pageTitle: "@!#%", fileName: "@!%23%"},
@@ -127,7 +126,7 @@ test('special page names', async ({ page, block, graphDir }) => {
     const text = `content for ${pageTitle}`
     await block.mustFill(text)
     await page.keyboard.press("Enter")
-    
+
     // Wait for the file to be created on disk
     await page.waitForTimeout(2000);
     // Validate that the file is created on disk with the content

+ 1 - 1
e2e-tests/util/search-modal.ts

@@ -60,5 +60,5 @@ export async function searchPage(page: Page, query: string): Promise<ElementHand
     await page.fill('[placeholder="What are you looking for?"]', query)
     await page.waitForTimeout(2000) // wait longer for search contents to render
 
-    return page.$$('#ui__ac-inner>div');
+    return page.$$('.search-results>div');
 }

+ 22 - 22
src/main/frontend/components/cmdk.cljs

@@ -449,35 +449,35 @@
             "Show more"
             (shui/shortcut "mod down" context)])])]
 
-     [:div
+     [:div.search-results
       (for [item visible-items
             :let [highlighted? (= item highlighted-item)]]
-        (ui/lazy-visible
-         (fn []
-           (shui/list-item (assoc item
-                                  :query (when-not (= group :create) @(::input state))
-                                  :compact true
-                                  :rounded false
-                                  :highlighted highlighted?
-                                  :display-shortcut-on-highlight? true
+        (let [item (shui/list-item (assoc item
+                                          :query (when-not (= group :create) @(::input state))
+                                          :compact true
+                                          :rounded false
+                                          :highlighted highlighted?
+                                          :display-shortcut-on-highlight? true
                                ;; for some reason, the highlight effect does not always trigger on a
                                ;; boolean value change so manually pass in the dep
-                                  :on-highlight-dep highlighted-item
-                                  :on-click (fn [e]
-                                              (reset! (::highlighted-item state) item)
-                                              (handle-action :default state item)
-                                              (when-let [on-click (:on-click item)]
-                                                (on-click e)))
+                                          :on-highlight-dep highlighted-item
+                                          :on-click (fn [e]
+                                                      (reset! (::highlighted-item state) item)
+                                                      (handle-action :default state item)
+                                                      (when-let [on-click (:on-click item)]
+                                                        (on-click e)))
                                ;; :on-mouse-enter (fn [e]
                                ;;                   (when (not highlighted?)
                                ;;                     (reset! (::highlighted-item state) (assoc item :mouse-enter-triggered-highlight true))))
-                                  :on-highlight (fn [ref]
-                                                  (reset! (::highlighted-group state) group)
-                                                  (when (and ref (.-current ref)
-                                                             (not (:mouse-enter-triggered-highlight @(::highlighted-item state))))
-                                                    (scroll-into-view-when-invisible state (.-current ref)))))
-                           context))
-         {:trigger-once? true}))]]))
+                                          :on-highlight (fn [ref]
+                                                          (reset! (::highlighted-group state) group)
+                                                          (when (and ref (.-current ref)
+                                                                     (not (:mouse-enter-triggered-highlight @(::highlighted-item state))))
+                                                            (scroll-into-view-when-invisible state (.-current ref)))))
+                                   context)]
+          (if (= group :blocks)
+            (ui/lazy-visible (fn [] item) {:trigger-once? true})
+            item)))]]))
 
 (defn move-highlight [state n]
   (let [items (mapcat last (state->results-ordered state (:search/mode @state/state)))