refactor: extract dynamic value resolution into BlockValueResolver#664
refactor: extract dynamic value resolution into BlockValueResolver#664stravo1 wants to merge 1 commit into
Conversation
Consolidate duplicated attribute/style/innerHTML resolution logic from BlockHTML, TextBlock, and BuilderBlock into a shared class, and simplify BuilderBlock's hover/selection state to computed properties.
Confidence Score: 4/5Refactor is functionally correct; the one divergence (watch running in preview mode) is harmless. The No files require special attention; Reviews (1): Last reviewed commit: "refactor: extract dynamic value resoluti..." | Re-trigger Greptile |
| watch( | ||
| selectedInCanvas, | ||
| (selected, _, onCleanup) => { | ||
| if (!selected || !props.block.isImage()) { | ||
| isSelected.value = selected; | ||
| return; | ||
| } | ||
|
|
||
| // Preserve double-click image uploads before showing the selection editor. | ||
| const timeout = setTimeout(() => { | ||
| isSelected.value = true; | ||
| }, 200); | ||
| onCleanup(() => clearTimeout(timeout)); | ||
| }, | ||
| { immediate: true }, | ||
| ); |
There was a problem hiding this comment.
isSelected watch now runs in preview mode
The original code guarded both watchers with if (!props.preview). The new unconditional watch fires in preview mode on every selection change — selectedInCanvas always returns false there, so isSelected.value = false is re-assigned unnecessarily on every canvas selection event. Not a correctness bug, but adds reactive overhead in preview contexts.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #664 +/- ##
========================================
Coverage 56.54% 56.54%
========================================
Files 34 34
Lines 4119 4119
========================================
Hits 2329 2329
Misses 1790 1790 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Consolidate duplicated attribute/style/innerHTML resolution logic from BlockHTML, TextBlock, and BuilderBlock into a shared class, and simplify BuilderBlock's hover/selection state to computed properties.