Browse Source

fix: pages not displaying their page properties

on initial load. Page properties would only show up
after clicking on Configure which is confusing and made the initial
page load seem buggy
Gabriel Horner 1 year ago
parent
commit
27aca24199

+ 15 - 12
src/main/frontend/components/db_based/page.cljs

@@ -17,7 +17,10 @@
             [clojure.string :as string]
             [clojure.string :as string]
             [logseq.db.frontend.property :as db-property]))
             [logseq.db.frontend.property :as db-property]))
 
 
-(rum/defc page-properties < rum/reactive
+(rum/defc page-properties
+  "This component is called by page-inner and within configure/info modal. This should not
+   be displaying properties from both components at the same time"
+  < rum/reactive
   [page {:keys [mode configure?]}]
   [page {:keys [mode configure?]}]
   (let [class? (= mode :class)
   (let [class? (= mode :class)
         edit-input-id-prefix (str "edit-block-" (:block/uuid page))
         edit-input-id-prefix (str "edit-block-" (:block/uuid page))
@@ -32,23 +35,23 @@
                (or has-viewable-properties?
                (or has-viewable-properties?
                    has-class-properties?)))
                    has-class-properties?)))
       [:div.ls-page-properties
       [:div.ls-page-properties
-       {:class (util/classnames [{:no-mode (nil? mode)
-                                  :no-properties (if class?
+       {:class (util/classnames [{:no-properties (if class?
                                                    (not has-class-properties?)
                                                    (not has-class-properties?)
                                                    (not has-viewable-properties?))}])}
                                                    (not has-viewable-properties?))}])}
-       (cond
-         (= mode :class)
-         (if (and config/publishing? (not configure?))
-           (component-block/db-properties-cp {:editor-box editor/box}
-                                             page
-                                             (str edit-input-id-prefix "-page")
-                                             (assoc configure-opts :class-schema? false))
+       (if configure?
+         (cond
+           (= mode :class)
            (component-block/db-properties-cp {:editor-box editor/box}
            (component-block/db-properties-cp {:editor-box editor/box}
                                              page
                                              page
                                              (str edit-input-id-prefix "-schema")
                                              (str edit-input-id-prefix "-schema")
-                                             (assoc configure-opts :class-schema? true)))
+                                             (assoc configure-opts :class-schema? true))
 
 
-         (= mode :page)
+           (= mode :page)
+           (component-block/db-properties-cp {:editor-box editor/box}
+                                             page
+                                             (str edit-input-id-prefix "-page")
+                                             (assoc configure-opts :class-schema? false :page? true)))
+         ;; default view for page-inner
          (component-block/db-properties-cp {:editor-box editor/box}
          (component-block/db-properties-cp {:editor-box editor/box}
                                            page
                                            page
                                            (str edit-input-id-prefix "-page")
                                            (str edit-input-id-prefix "-page")

+ 1 - 1
src/main/frontend/components/page.cljs

@@ -549,7 +549,7 @@
                        [:div.mb-4
                        [:div.mb-4
                         (component-block/breadcrumb config repo block-id {:level-limit 3})]))
                         (component-block/breadcrumb config repo block-id {:level-limit 3})]))
 
 
-                   (when (and db-based? (not block?) (not preview?))
+                   (when (and db-based? (not block?) (not preview?) (not (::show-page-info? state)))
                      (db-page/page-properties-react page {:configure? false}))
                      (db-page/page-properties-react page {:configure? false}))
 
 
                    ;; blocks
                    ;; blocks