🐛 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
This commit is contained in:
alonso.torres 2026-11-24 16:51:51 +01:00
parent 243502d77c
commit d796255597

View File

@ -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