mirror of
https://github.com/penpot/penpot.git
synced 2026-09-19 18:36:14 +00:00
* 🐛 Reflow auto grid cells on flow direction change Remap only single-span auto cells to the new :layout-grid-dir traversal order, keeping source order, manual and area placements untouched. Update both grid direction controls to use the new change-grid-direction event and refresh the stale active button on persisted direction. Add a RED-to-GREEN model regression covering a 2x2 row-to-column transition and source-order. AI-assisted-by: muse-spark Signed-off-by: makesomethingshit <junsoo1172@gmail.com> * 🐛 Keep source order on grid flow change with areas Skip the generic grid cell pass for the direction event, since reflowing already places every eligible auto item and a blind reorder rewrites shapes around pinned areas. Pin area/span grids with a regression test covering direction change and source order. AI-assisted-by: muse-spark Signed-off-by: makesomethingshit <junsoo1172@gmail.com> * 🐛 Scope grid skip to direction changes only Replace the translation flag with a narrow skip-grid-reassignment option so component sync and reflow metadata stay intact while the generic grid cell pass is skipped. AI-assisted-by: muse-spark Signed-off-by: makesomethingshit <junsoo1172@gmail.com> * 🐛 Clear leftover auto cells on grid flow change Write remapped shapes to every target auto cell and empty leftover cells so sparse grids cannot duplicate a child across target cells. Manual, area and spanned cells stay untouched; source order is kept. AI-assisted-by: muse-spark Signed-off-by: makesomethingshit <junsoo1172@gmail.com> * 🐛 Pin grid flow invariants with span and manual regressions Keep the direction-change design unchanged and lock the claimed invariants with tests: a real 2x1 manual span cell and an occupied manual cell stay byte-identical, row->column->row round-trips to the original cells, and a mixed auto/manual/span/area grid shows no shape loss or duplication. Also drop the unused page-objects binding from the direction-change watcher. AI-assisted-by: muse-spark Signed-off-by: makesomethingshit <junsoo1172@gmail.com> * 🐛 Unoverlap mixed grid fixture and assert movement Move auto C to (1,3) so it no longer overlaps the 2x1 manual span at (1,2). Row auto order A,C,B,E becomes column order A,B,E,C; assert the exact placement while keeping pinned, source-order and no-loss checks. Test-only change. AI-assisted-by: muse-spark Signed-off-by: makesomethingshit <junsoo1172@gmail.com> * 🐛 Unify plugin dir setter and normalize missing direction Route GridLayoutProxy.dir through change-grid-direction so the plugin API shares the UI direction-change path with its reflow and source-order guarantees. Normalize a missing :layout-grid-dir to :row at the change-grid-direction entry point and cover it with a missing-direction regression plus a plugin setter routing regression. AI-assisted-by: muse-spark Signed-off-by: makesomethingshit <junsoo1172@gmail.com> * 🐛 Fix grid plugin dir setter syntax Signed-off-by: makesomethingshit <junsoo1172@gmail.com> AI-assisted-by: opencode-go/muse-spark-1.3-contributor * 🐛 Fix comments and tests --------- Signed-off-by: makesomethingshit <junsoo1172@gmail.com> Co-authored-by: alonso.torres <alonso.torres@kaleidos.net>
65 lines
2.6 KiB
Clojure
65 lines
2.6 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
|
|
|
(ns frontend-tests.plugins.grid-test
|
|
(:require
|
|
[app.common.test-helpers.files :as cthf]
|
|
[app.main.store :as st]
|
|
[app.plugins.api :as api]
|
|
[app.plugins.utils :as u]
|
|
[cljs.test :as t :include-macros true]
|
|
[frontend-tests.helpers.state :as ths]
|
|
[frontend-tests.helpers.wasm :as thw]
|
|
[potok.v2.core :as ptk]))
|
|
|
|
(def ^:private plugin-id "00000000-0000-0000-0000-000000000000")
|
|
|
|
(defn- setup-grid []
|
|
(let [store (ths/setup-store (cthf/sample-file :file1 :page-label :page1))
|
|
_ (set! st/state store)
|
|
_ (set! st/stream (ptk/input-stream store))
|
|
context (api/create-context plugin-id)
|
|
board (.createBoard ^js context)
|
|
grid (.addGridLayout ^js board)]
|
|
{:store store :context context :board board :grid grid}))
|
|
|
|
(t/deftest add-column-at-index-accepts-fixed-track-type
|
|
(thw/with-wasm-mocks*
|
|
(fn []
|
|
(let [{:keys [^js grid]} (setup-grid)]
|
|
(.addColumn grid "flex" 1)
|
|
(.addColumnAtIndex grid 0 "fixed" 100)
|
|
(t/is (= "fixed" (aget (aget (.-columns grid) 0) "type")))
|
|
(t/is (= 100 (aget (aget (.-columns grid) 0) "value")))))))
|
|
|
|
(t/deftest grid-track-methods-reject-out-of-range-indices
|
|
(thw/with-wasm-mocks*
|
|
(fn []
|
|
(let [{:keys [store ^js grid]} (setup-grid)]
|
|
(swap! store assoc-in [:plugins :flags plugin-id :throw-validation-errors] true)
|
|
(.addRow grid "flex" 1)
|
|
(.addColumn grid "flex" 1)
|
|
(t/is (thrown? js/Error (.addRowAtIndex grid -1 "fixed" 10)))
|
|
(t/is (thrown? js/Error (.addColumnAtIndex grid 2 "fixed" 10)))
|
|
(t/is (thrown? js/Error (.setRow grid 1 "fixed" 10)))
|
|
(t/is (thrown? js/Error (.setColumn grid 1 "fixed" 10)))
|
|
(t/is (thrown? js/Error (.removeRow grid 1)))
|
|
(t/is (thrown? js/Error (.removeColumn grid 1)))))))
|
|
|
|
(t/deftest grid-dir-setter-persists-implicit-row
|
|
(thw/with-wasm-mocks*
|
|
(fn []
|
|
(let [{:keys [store ^js grid]} (setup-grid)
|
|
file-id (:current-file-id @store)
|
|
page-id (:current-page-id @store)
|
|
grid-id (:id (u/proxy->shape grid))]
|
|
(swap! store update-in
|
|
[:files file-id :data :pages-index page-id :objects grid-id]
|
|
dissoc
|
|
:layout-grid-dir)
|
|
(set! (.-dir grid) "row")
|
|
(t/is (= "row" (.-dir grid)))))))
|