fix: element creation fails with empty layer_id (FOREIGN KEY constraint)
Three fixes: 1. interaction/index.ts: Add layerId to created element in confirmDraw() 2. CanvasArea.tsx: Sync layers to LayerManager via layerManagerRef 3. App.tsx: Fallback to activeLayerId in handleElementCreated if layerId missing Root cause: LayerManager.activeLayerId was empty because layers were never synced from React state to the interaction layer LayerManager. New elements got layer_id="" which failed SQLite FOREIGN KEY constraint. Also includes Yjs sync race condition fix from previous commit.
This commit is contained in:
@@ -961,7 +961,7 @@ export class InteractionEngine {
|
||||
} else if (this.state.activeTool === 'revcloud' && this.state.points.length >= 2) {
|
||||
el = dimService.createRevCloud(this.state.points, layerId);
|
||||
} else {
|
||||
el = { ...this.state.previewElement, id: this.generateId() };
|
||||
el = { ...this.state.previewElement, id: this.generateId(), layerId: layerId };
|
||||
}
|
||||
|
||||
this.onElementCreated?.(el);
|
||||
|
||||
Reference in New Issue
Block a user