Przeglądaj źródła

fix: stable sort order

Tienson Qin 8 miesięcy temu
rodzic
commit
c826d13786
1 zmienionych plików z 5 dodań i 9 usunięć
  1. 5 9
      src/main/frontend/components/property/value.cljs

+ 5 - 9
src/main/frontend/components/property/value.cljs

@@ -31,7 +31,6 @@
             [goog.dom :as gdom]
             [goog.functions :refer [debounce]]
             [lambdaisland.glogi :as log]
-            [logseq.common.util :as common-util]
             [logseq.common.util.macro :as macro-util]
             [logseq.db :as ldb]
             [logseq.db.frontend.content :as db-content]
@@ -619,15 +618,12 @@
   [property selected-choices items]
   (if (:property/closed-values property)
     items                   ; sorted by order
-    (sort
-     (common-util/by-sorting
-      [{:get-value db-property/property-value-content
-        :asc? true}
-       {:get-value (fn [item] (selected-choices (:db/id item)))
-        :asc? false}])
+    (sort-by
+     (juxt (fn [item] (not (selected-choices (:db/id item))))
+           db-property/property-value-content)
      items)))
 
-(defn- select-aux
+(rum/defc select-aux
   [block property {:keys [items selected-choices multiple-choices?] :as opts}]
   (let [selected-choices (->> selected-choices
                               (remove nil?)
@@ -637,7 +633,7 @@
         clear-value-label [:div.flex.flex-row.items-center.gap-1.text-sm
                            (ui/icon "x" {:size 14})
                            [:div clear-value]]
-        items (sort-select-items property selected-choices items)
+        [items _] (hooks/use-state (sort-select-items property selected-choices items))
         items' (->>
                 (if (and (seq selected-choices)
                          (not multiple-choices?)