fix(Avatar): forward attrs to root when there is no image - #6898
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthrough
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized fix forwards Avatar attributes to the correct root or image element, restoring expected anchoring and state styling without introducing an actionable merge-blocking risk. It is merge-ready after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Linked Issues checkExplanation The changes address issue Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
src/runtime/components/Avatar.vueParsing error: Unexpected token ) 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 |
Merging this PR will improve performance by 11.03%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | plain <button> |
1.3 ms | 1.2 ms | +11.03% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing lazerg:fix/issue-6896-avatar-root-attrs (24863e8) with v4 (ae24311)
commit: |
|
The failing playground job is not caused by this change. It fails the same way on v4 itself, where |
🔗 Linked issue
Resolves #6896
❓ Type of change
📚 Description
AvatarsetsinheritAttrs: falseand never binds$attrson its root. Without asrcthe attributes went through aSlotaround the default slot, so they landed on whatever ended up inside the avatar. With nothing but the fallback there,<UDropdownMenu><UAvatar alt="TEST" /></UDropdownMenu>rendered the trigger id,aria-haspopup,aria-expandedanddata-stateon the inner<span data-slot="fallback">instead of the root.That inner span is only as wide as the initials, so the menu anchored to the text rather than to the circle and clicking anywhere else on the avatar did nothing. Themes keyed on
data-[state=open]on the root were also never applied. The same thing was reported before in #2923, #3699 and #3710, and each time the attributes were moved further down rather than up to the root.They now go to the root whenever no image is rendered, which covers the fallback, the icon, a custom default slot and a
srcthat fails to load. When an image is rendered they still go to the<img>, the same split asBanner, so the native<img>attributes documented on this component (loading,crossorigin, …) keep working. One case is left out: with thechipprop the root is aUChip, which forwards its own$attrsto its slot, so the attributes still end up on the avatar content there.📝 Checklist