Merge pull request #9614 from penpot/elenatorro-fix-text-focus-on-empty-text-shape

🐛 Fix text focus on empty text
This commit is contained in:
Alejandro Alonso 2026-05-14 07:26:30 +02:00 committed by GitHub
commit 009d805394
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -290,8 +290,8 @@
:data-testid "text-editor-container"
:style {:width "var(--editor-container-width)"
:height "var(--editor-container-height)"
:min-width "1px"
:min-height "1px"}}
:min-width "var(--editor-container-min-width, 1px)"
:min-height "var(--editor-container-min-height, 1px)"}}
;; We hide the editor when is blurred because otherwise the
;; selection won't let us see the underlying text. Use opacity
;; because display or visibility won't allow to recover focus
@ -381,7 +381,7 @@
render-wasm? (mf/use-memo #(features/active-feature? @st/state "render-wasm/v1"))
[{:keys [x y width height]} transform]
[{:keys [x y width height selrect-width selrect-height]} transform]
(if render-wasm?
(let [{:keys [width height]} (wasm.api/get-text-dimensions shape-id)
selrect-transform (mf/deref refs/workspace-selrect)
@ -403,7 +403,8 @@
"bottom" (+ y (- selrect-height height))
"center" (+ y (/ (- selrect-height height) 2))
y)]
[(assoc selrect :y y :width overlay-width :height max-height) transform])
[(assoc selrect :y y :width overlay-width :height max-height
:selrect-width selrect-width :selrect-height selrect-height) transform])
(let [bounds (gst/shape->rect shape)
x (mth/min (dm/get-prop bounds :x)
@ -422,6 +423,8 @@
(obj/merge!
#js {"--editor-container-width" "auto"
"--editor-container-height" "auto"
"--editor-container-min-width" (dm/str selrect-width "px")
"--editor-container-min-height" (dm/str selrect-height "px")
"--fallback-families" (if (seq fallback-families) (dm/str (str/join ", " fallback-families)) "sourcesanspro")
:display "flex"})