fix(core): resolve inspector text edits for mixed-children pass-throughs - #254
fix(core): resolve inspector text edits for mixed-children pass-throughs#254yen0304 wants to merge 1 commit into
Conversation
collectElementTextCandidates only resolved a {children}/prop pass-through to its call
sites when it was the host element's sole meaningful child (propPassthroughName bailed
when meaningfulChildren(element).length !== 1). A host like
<div><span>{label}</span>{children}</div> therefore matched none of the fallbacks and the
inspector reported "element has no editable text".
Collect pass-through names from the element's direct children instead, so a {children}
or prop pass-through mixed with other children still resolves to the call site.
|
@yen0304 is attempting to deploy a commit to the open-slide Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughReplaces the single-passthrough heuristic ( ChangesInspector mixed-children passthrough fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #212
Problem
Inspector inline text editing fails with
element has no editable textwhenever the clicked text maps to a host element whose children are mixed — i.e. a{children}/prop pass-through alongside other children, with no literal text of its own:Root cause
collectElementTextCandidates()falls back to resolving a pass-through to its call sites viapropPassthroughName(), which bails out unless the pass-through is the element’s sole meaningful child:So an element that mixes
{children}(or a{prop}) with anything else matches none of the three fallbacks, andbuildTextSplice()returnselement has no editable text.Fix
Collect pass-through names from the element’s direct children instead of requiring a single child. A
{children}or{prop}expression container that sits next to other children is still resolved to the matching call site(s). This only adds resolutions that previously failed — the sole-child cases behave exactly as before.Tests
Added two cases to
edit-ops.test.ts, both of which fail onmain(element has no editable text) and pass with this change:{children}slot mixed with a nested{label}span, edited with noprevText;{prop}pass-through mixed with a{children}slot, routed to thetitle="…"literal at the call site.pnpm vitest run packages/core— 243 passing, andpnpm --filter @open-slide/core typecheckis clean.Summary by CodeRabbit
{children}and/or prop pass-through with additional children.