diff --git a/src/main/frontend/components/views.cljs b/src/main/frontend/components/views.cljs index a11372bf6d..b3fc02c13d 100644 --- a/src/main/frontend/components/views.cljs +++ b/src/main/frontend/components/views.cljs @@ -513,13 +513,8 @@ [:div.table-action-bar.absolute.top-0.left-8 (action-bar table selected-rows option)])))) -(rum/defc row-cell < rum/static - [table row column render cell-opts] - (shui/table-cell cell-opts - (render table row column))) - (rum/defc table-row-inner < rum/static - [{:keys [row-selected?] :as table} row props {:keys [show-add-property?]}] + [{:keys [row-selected?] :as table} row props {:keys [show-add-property? scrolling?]}] (let [pinned-columns (get-in table [:state :pinned-columns]) unpinned (get-in table [:state :unpinned-columns]) unpinned-columns (if show-add-property? @@ -528,34 +523,34 @@ :cell (fn [_table _row _column])}) unpinned) sized-columns (get-in table [:state :sized-columns]) - row-cell-f (fn [column] + row-cell-f (fn [column {:keys [hide?]}] (let [id (str (:id row) "-" (:id column)) render (get column :cell) width (get-column-size column sized-columns) select? (= (:id column) :select) add-property? (= (:id column) :add-property) + style {:width width :min-width width} cell-opts {:key id :select? select? :add-property? add-property? - :style {:width width - :min-width width}}] - (when render - (row-cell table row column render cell-opts)))) - pin-count (count pinned-columns)] + :style style}] + (if hide? + [:div.h-8 {:style style}] + (when render + (shui/table-cell cell-opts (render table row column))))))] (shui/table-row (merge props {:key (str (:id row)) :data-state (when (row-selected? row) "selected")}) [:div.sticky-columns.flex.flex-row - (map row-cell-f pinned-columns)] + (map #(row-cell-f % {}) pinned-columns)] [:div.flex.flex-row - (map-indexed (fn [idx column] - (let [lazy? (> (+ pin-count idx) 5)] - (if lazy? - (ui/lazy-visible - (fn [] (row-cell-f column))) - (row-cell-f column)))) unpinned-columns)]))) + (let [pin-count (count pinned-columns)] + (map-indexed (fn [idx column] + (if (and (> (+ pin-count idx) 5) scrolling?) + (row-cell-f column {:hide? true}) + (row-cell-f column {}))) unpinned-columns))]))) (rum/defc table-row < rum/reactive db-mixins/query [table row props option] @@ -1100,23 +1095,27 @@ (rum/defc table-body < rum/static [table option rows *scroller-ref *rows-wrap set-items-rendered!] - (ui/virtualized-list - {:ref #(reset! *scroller-ref %) - :custom-scroll-parent (or (some-> (rum/deref *rows-wrap) (.closest ".sidebar-item-list")) - (gdom/getElement "main-content-container")) - :increase-viewport-by {:top 300 :bottom 300} - :compute-item-key (fn [idx] - (let [block (nth rows idx)] - (str "table-row-" (:db/id block)))) - :skipAnimationFrameInResizeObserver true - :total-count (count rows) - :item-content (fn [idx] - (let [row (nth rows idx)] - (table-row table row {} option))) - :items-rendered (fn [props] - (when (seq props) - (set-items-rendered! true))) - :end-reached (:end-reached option)})) + (let [[scrolling? set-scrolling!] (rum/use-state false)] + (ui/virtualized-list + {:ref #(reset! *scroller-ref %) + :custom-scroll-parent (or (some-> (rum/deref *rows-wrap) (.closest ".sidebar-item-list")) + (gdom/getElement "main-content-container")) + :increase-viewport-by {:top 300 :bottom 300} + :compute-item-key (fn [idx] + (let [block (nth rows idx)] + (str "table-row-" (:db/id block)))) + :skipAnimationFrameInResizeObserver true + :total-count (count rows) + :item-content (fn [idx _user ^js context] + (let [scrolling? (.-scrolling context) + row (nth rows idx)] + (table-row table row {} (assoc option :scrolling? scrolling?)))) + :items-rendered (fn [props] + (when (seq props) + (set-items-rendered! true))) + :context {:scrolling scrolling?} + :is-scrolling set-scrolling! + :end-reached (:end-reached option)}))) (rum/defc table-view < rum/static [table option row-selection *scroller-ref] @@ -1579,10 +1578,10 @@ (str "view-" (:db/id view-entity'))))) (defn-