Parcourir la source

fix: react key warnings

Tienson Qin il y a 1 an
Parent
commit
dd294992a7

+ 15 - 13
deps/shui/src/logseq/shui/shortcut/v1.cljs

@@ -1,8 +1,8 @@
 (ns logseq.shui.shortcut.v1
   (:require [clojure.string :as string]
+            [goog.userAgent]
             [logseq.shui.base.core :as shui.base]
-            [rum.core :as rum]
-            [goog.userAgent]))
+            [rum.core :as rum]))
 
 (def mac? goog.userAgent/MAC)
 (defn print-shortcut-key [key]
@@ -57,15 +57,15 @@
         interactive? (true? interactive?)]
     (shui.base/button {:variant (if interactive? :default :text)
                        :class (str "bg-gray-03 text-gray-10 px-1.5 py-0 leading-4 h-5 rounded font-normal "
-                                (if interactive?
-                                  "hover:bg-gray-04 active:bg-gray-03 hover:text-gray-12"
-                                  "bg-transparent cursor-default active:bg-gray-03 hover:text-gray-11 opacity-80"))
+                                   (if interactive?
+                                     "hover:bg-gray-04 active:bg-gray-03 hover:text-gray-12"
+                                     "bg-transparent cursor-default active:bg-gray-03 hover:text-gray-11 opacity-80"))
                        :size size}
-      (for [[index tile] (map-indexed vector tiles)]
-        [:<>
-         (when (< 0 index)
-           [:span.ui__button__tile-separator])
-         [:span.ui__button__tile tile]]))))
+                      (for [[index tile] (map-indexed vector tiles)]
+                        [:<>
+                         (when (< 0 index)
+                           [:span.ui__button__tile-separator])
+                         [:span.ui__button__tile tile]]))))
 
 (rum/defc root
   [shortcut & {:keys [size theme interactive?]
@@ -80,8 +80,10 @@
       (for [[index binding] (map-indexed vector shortcuts)]
         [:<>
          (when (< 0 index)
-           [:div.text-gray-11.text-sm "|"])
+           [:div.text-gray-11.text-sm {:key "sep"} "|"])
          (if (coll? (first binding))   ; + included
-           (for [ks binding]
-             (part ks size opts))
+           (for [[idx ks] (map-indexed vector binding)]
+             (rum/with-key
+               (part ks size opts)
+               (str "part-" idx)))
            (part binding size opts))]))))

+ 5 - 3
src/main/frontend/components/container.cljs

@@ -144,8 +144,9 @@
                           (util/stop e))}
        (ldb/object? page)
        (assoc :title (block-handler/block-unique-title page)))
-     [:span.page-icon icon]
-     [:span.page-title {:class (when untitled? "opacity-50")
+     [:span.page-icon {:key "page-icon"} icon]
+     [:span.page-title {:key "title"
+                        :class (when untitled? "opacity-50")
                         :style {:display "ruby"}}
       (cond
         (not (db/page? page))
@@ -159,7 +160,8 @@
 
      ;; dots trigger
      (shui/button
-      {:size :sm
+      {:key "more actions"
+       :size :sm
        :variant :ghost
        :class "absolute !bg-transparent right-0 top-0 px-1.5 scale-75 opacity-40 hidden group-hover:block hover:opacity-80 active:opacity-100"
        :on-click #(do