🐛 Fix selrect auto-width on selrect click and selrect resize (#11541)

* 🐛 Fix text edge double click needing two undos

* 🐛 Fix text font change needing two undos
This commit is contained in:
Elena Torró 2026-09-08 13:32:37 +02:00 committed by GitHub
parent af5b767933
commit 18e641d79a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 20 deletions

View File

@ -123,7 +123,8 @@
(defn- await-font-faces (defn- await-font-faces
"Waits for missing WASM faces, then resizes the affected texts." "Waits for missing WASM faces, then resizes the affected texts."
[stream face-keys ids] [stream face-keys ids]
(let [resize-stream (->> (rx/from ids) (rx/map dwwt/resize-wasm-text))] (let [resize-opts {:stack-undo? true :undo-transation? false}
resize-stream (->> (rx/from ids) (rx/map #(dwwt/resize-wasm-text % resize-opts)))]
(if (empty? face-keys) (if (empty? face-keys)
resize-stream resize-stream
(->> (rx/merge wasm.fonts/font-stored-stream (->> (rx/merge wasm.fonts/font-stored-stream

View File

@ -79,20 +79,26 @@
(defn resize-wasm-text (defn resize-wasm-text
"Resize a single text shape (auto-width/auto-height) by id. "Resize a single text shape (auto-width/auto-height) by id.
No-op if the id is not a text shape or is :fixed." No-op if the id is not a text shape or is :fixed.
[id] `opts` are forwarded to `apply-wasm-modifiers`, so a caller whose undo
(ptk/reify ::resize-wasm-text transaction is already closed when the resize lands can still get the
ptk/WatchEvent geometry into the right undo entry."
(watch [_ state _] ([id]
(let [objects (dsh/lookup-page-objects state) (resize-wasm-text id nil))
shape (get objects id) ([id opts]
resize-stream (ptk/reify ::resize-wasm-text
(if (and (some? shape) ptk/WatchEvent
(cfh/text-shape? shape) (watch [_ state _]
(not= :fixed (:grow-type shape))) (let [objects (dsh/lookup-page-objects state)
(rx/of (dwm/apply-wasm-modifiers (resize-wasm-text-modifiers shape))) shape (get objects id)
(rx/empty))] apply-opts (or opts {})
(wrf/with-pending :text-resize [id] resize-stream))))) resize-stream
(if (and (some? shape)
(cfh/text-shape? shape)
(not= :fixed (:grow-type shape)))
(rx/of (dwm/apply-wasm-modifiers (resize-wasm-text-modifiers shape) apply-opts))
(rx/empty))]
(wrf/with-pending :text-resize [id] resize-stream))))))
(defn resize-wasm-text-debounce-commit (defn resize-wasm-text-debounce-commit
([] ([]

View File

@ -18,6 +18,7 @@
[app.main.data.helpers :as dsh] [app.main.data.helpers :as dsh]
[app.main.data.workspace :as dw] [app.main.data.workspace :as dw]
[app.main.data.workspace.shapes :as dwsh] [app.main.data.workspace.shapes :as dwsh]
[app.main.data.workspace.undo :as dwu]
[app.main.data.workspace.wasm-text :as dwwt] [app.main.data.workspace.wasm-text :as dwwt]
[app.main.features :as features] [app.main.features :as features]
[app.main.refs :as refs] [app.main.refs :as refs]
@ -307,11 +308,14 @@
:bottom :auto-height :bottom :auto-height
nil)] nil)]
(when (some? grow-type) (when (some? grow-type)
(st/emit! (dwsh/update-shapes [shape-id] #(assoc % :grow-type grow-type))) (let [uid (js/Symbol)]
;; The WASM renderer needs an explicit reflow after the grow-type change (st/emit! (dwu/start-undo-transaction uid)
(when (features/active-feature? @st/state "render-wasm/v1") (dwsh/update-shapes [shape-id] #(assoc % :grow-type grow-type)))
(st/emit! (dwwt/resize-wasm-text-all [shape-id]) ;; The WASM renderer needs an explicit reflow after the grow-type change
(ptk/data-event :layout/update {:ids [shape-id]}))))))))] (if (features/active-feature? @st/state "render-wasm/v1")
(st/emit! (dwwt/resize-wasm-text-all [shape-id] {:undo-id uid})
(ptk/data-event :layout/update {:ids [shape-id]}))
(st/emit! (dwu/commit-undo-transaction uid)))))))))]
[:g.resize-handler [:g.resize-handler
(when ^boolean show-handler (when ^boolean show-handler