fix: add missing size property to DynamicIcon class#5663
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR fixes a bug where the size attribute was ignored when using dynamic state variables with rx.icon. The issue stemmed from an inconsistency between two icon rendering paths in the codebase:
- Static icons use the
Iconclass which has asize: Var[int]property defined (line 24) - Dynamic icons use the
DynamicIconclass which was missing this property definition
When IconButton.create() processes icons, it expects both static and dynamic icons to accept the size parameter as a component property. The IconButton class automatically sets icon sizes based on its own size prop, defaulting to "12px" if not specified. Without the size property in DynamicIcon, this parameter was being treated as a CSS style rather than a component prop, causing dynamic icons to fall back to Lucide React's default 24px size.
The fix adds the missing size: Var[int] property to the DynamicIcon class (line 96), ensuring both icon types have identical API surfaces. This change maintains consistency in the component hierarchy where both Icon and DynamicIcon inherit from LucideIconComponent and should expose the same properties for size handling.
Confidence score: 5/5
- This PR is safe to merge with minimal risk
- Score reflects a simple property addition that fixes a clear inconsistency between related classes
- No files require special attention
1 file reviewed, no comments
|
that looks correct, running |
CodSpeed Performance ReportMerging #5663 will not alter performanceComparing Summary
Footnotes |
a055fff to
a1432bc
Compare
All Submissions:
Type of change
Changes To Core Features:
Description
Fixes #5660 where
rx.iconsize attribute was ignored when using dynamic state variables vs static strings.The DynamicIcon class was missing the size: Var[int] property definition, causing size to be treated as CSS style instead of a direct component prop. This resulted in dynamic icons falling back to Lucide React's default size of 24px instead of using the specified size.
Problem
rx.icon("home", size=16)worked correctly (16x16 pixels)rx.icon(State.icon, size=16)was broken (fell back to Lucide's default 24px)Root Cause
The
DynamicIconclass was missing thesize: Var[int]property definition, causing the size parameter to be treated as a CSS style instead of a direct componentprop.
Solution
Added the missing
size: Var[int]property to theDynamicIconclass, ensuring consistent size handling between static and dynamic icons.Testing
closes #5660