Skip to content

refactor: extract dynamic value resolution into BlockValueResolver#664

Open
stravo1 wants to merge 1 commit into
frappe:developfrom
stravo1:refactor-dynamic-value-resln
Open

refactor: extract dynamic value resolution into BlockValueResolver#664
stravo1 wants to merge 1 commit into
frappe:developfrom
stravo1:refactor-dynamic-value-resln

Conversation

@stravo1

@stravo1 stravo1 commented Jul 11, 2026

Copy link
Copy Markdown
Member

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.

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.
@stravo1
stravo1 requested a review from surajshetty3416 July 11, 2026 16:30
@greptile-apps

greptile-apps Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

Refactor is functionally correct; the one divergence (watch running in preview mode) is harmless.

The BlockValueResolver correctly defers all reactive reads through getter functions, so computed properties track their dependencies properly. The only change from the original behavior is the isSelected watch now subscribes in preview mode, which is redundant but not incorrect.

No files require special attention; blockValueResolver.ts is the only new file and its logic is straightforward.

Reviews (1): Last reviewed commit: "refactor: extract dynamic value resoluti..." | Re-trigger Greptile

Comment on lines +446 to +461
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 },
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.54%. Comparing base (7798234) to head (dec47ae).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant