fix(text-editor): prevent parent container from intercepting editor events

The canvas container's pointer handler was capturing ALL events when the text
tool was active, including clicks on the text editor UI (overlay, textarea,
handles). This prevented text selection, click-outside commit, and text
dragging from working.

Now the handler checks if the on-canvas editor is already active and returns
early, allowing the OnCanvasTextEditor to handle its own events properly.

Fixes:
- Text selection now works in textarea
- Clicking outside editor commits text
- Dragging transform handles moves text

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-21 15:10:22 +01:00
parent 0142b31a38
commit 910403c463

View File

@@ -69,7 +69,7 @@ export function CanvasWithTools() {
const { activeTool, settings } = useToolStore();
const { executeCommand } = useHistoryStore();
const { activeSelection, selectionType, isMarching } = useSelectionStore();
const { textObjects, editingTextId } = useTextStore();
const { textObjects, editingTextId, isOnCanvasEditorActive } = useTextStore();
const [marchingOffset, setMarchingOffset] = useState(0);
const [isPanning, setIsPanning] = useState(false);
@@ -227,8 +227,11 @@ export function CanvasWithTools() {
return;
}
// Text tool
// Text tool - only handle if editor is not already active
if (activeTool === 'text') {
// If editor is active, let it handle its own events (selection, dragging, click-outside)
if (isOnCanvasEditorActive) return;
const activeLayer = getActiveLayer();
if (!activeLayer || !activeLayer.canvas || activeLayer.locked) return;