Commit cf2f5cc
committed
fix(template-builder): selection highlight, 0,0 repositioning on z-index change
Bug 1 — Selection not working
Root cause: canvas.js was tracking _selectedUuid locally. When the layers
panel selected an element, the parent's selectedElement updated but the
canvas's _selectedUuid never changed, so @isSelected was always false.
Additionally, the canvas's {{on "click" handleDeselectAll}} was firing even
when a child element was tapped (interact.js tap does not stop the native
click from bubbling), immediately clearing the selection.
Fix:
- canvas.js: removed local _selectedUuid state entirely. selectedUuid is
now a getter derived from @selectedElement (the parent's source of truth).
This means any selection source (canvas tap, layers panel, keyboard) is
automatically reflected in the canvas highlight.
- canvas.js: handleDeselectAll now guards with
event.target !== event.currentTarget so it only fires when the canvas
background itself is clicked, not when a child element is tapped.
Bug 2 — z-index change repositions all elements to 0,0
Root cause: reorderElement replaces element objects with new spread copies.
Glimmer re-renders the ElementRenderer's style attribute (wrapperStyle).
wrapperStyle intentionally omits the CSS transform (which is managed
imperatively by interact.js). When Glimmer writes the new style attribute,
it clears the transform, snapping every element to 0,0.
Fix:
- element-renderer.hbs: added {{did-update this.handleUpdate @element}}.
- element-renderer.js: handleUpdate re-applies _applyTransform(el) after
Glimmer updates the style attribute, restoring the correct position.
Bonus fix — reorderElement now syncs selectedElement to the new object so
the properties panel reflects the updated z_index immediately.1 parent 7389a43 commit cf2f5cc
File tree
4 files changed
+29
-11
lines changed- addon/components
- template-builder
4 files changed
+29
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
341 | 346 | | |
342 | 347 | | |
343 | 348 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
| |||
70 | 67 | | |
71 | 68 | | |
72 | 69 | | |
73 | | - | |
| 70 | + | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
| |||
79 | 76 | | |
80 | 77 | | |
81 | 78 | | |
82 | | - | |
| 79 | + | |
| 80 | + | |
83 | 81 | | |
84 | 82 | | |
85 | 83 | | |
86 | 84 | | |
87 | 85 | | |
88 | 86 | | |
89 | | - | |
90 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 | | |
64 | 74 | | |
65 | 75 | | |
| |||
0 commit comments