From d796255597e29058ebfefff985496c6c822bbae0 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 24 Nov 2026 16:51:51 +0100 Subject: [PATCH] :bug: Keep the text editor from taking clicks outside the text The editor overlay reserves a viewport of room for the text to grow during an IME composition, and that room caught every pointer event, so a middle-button pan or a click to the right or below the text never reached the viewport. The overlay keeps its size, and its clip, which also limits hit testing, now covers only the text. AI-assisted-by: claude-opus-5-5 --- .../app/main/ui/workspace/shapes/text/v3_editor.cljs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/shapes/text/v3_editor.cljs b/frontend/src/app/main/ui/workspace/shapes/text/v3_editor.cljs index 919d02a959..90d22ba9b2 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/v3_editor.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/v3_editor.cljs @@ -396,7 +396,7 @@ fallback-families (map (fn [font] (font-family-from-font-id (:font-id font))) fallback-fonts) - [{:keys [x y width height ime-width ime-left]} transform] + [{:keys [x y width height ime-width ime-left hit-rect]} transform] (let [dimension (wasm.api/get-text-dimensions shape-id) selrect-transform (mf/deref refs/workspace-selrect) vbox (mf/deref refs/vbox) @@ -422,10 +422,13 @@ y top] ;; Widen the foreignObject (not the clip) toward the IME anchor, or ;; the browser scrolls to reveal the caret and cancels the offset. + ;; The clip keeps pointer events to the text itself, so the room + ;; reserved for growth does not take clicks from the viewport. [(assoc selrect :x x :y y :width overlay-width :height overlay-height :ime-width (+ overlay-width (:right ime-padding)) - :ime-left (:left ime-padding)) + :ime-left (:left ime-padding) + :hit-rect {:x left :y top :width (- right left) :height (- bottom top)}) transform]) schedule-ime-caret! @@ -1047,7 +1050,8 @@ :composition-base-ref composition-base-ref}] [:defs [:clipPath {:id clip-id} - [:rect {:x x :y y :width width :height height}]]] + [:rect {:x (:x hit-rect) :y (:y hit-rect) + :width (:width hit-rect) :height (:height hit-rect)}]]] [:foreignObject {:x (- x ime-left) :y y :width (+ ime-width ime-left) :height height} [:div {:on-click on-click