Skip to content

fix: add missing size property to DynamicIcon class#5665

Merged
adhami3310 merged 2 commits into
reflex-dev:mainfrom
geekalaa:fix-dynamic-icon-size-5660-updated
Aug 4, 2025
Merged

fix: add missing size property to DynamicIcon class#5665
adhami3310 merged 2 commits into
reflex-dev:mainfrom
geekalaa:fix-dynamic-icon-size-5660-updated

Conversation

@geekalaa
Copy link
Copy Markdown
Contributor

@geekalaa geekalaa commented Aug 4, 2025

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully ran tests with your changes locally?

Description

Fixes #5660 where rx.icon size 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 DynamicIcon class was missing the size: Var[int] property definition, causing the size parameter to be treated as a CSS style instead of a direct component
prop.

Solution

Added the missing size: Var[int] property to the DynamicIcon class, ensuring consistent size handling between static and dynamic icons.

Testing

  • Verified both static and dynamic icons now render with proper component props
  • All existing icon tests pass

closes #5660

  Fixes reflex-dev#5660 where rx.icon size 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.

  Changes:
  - Add size: Var[int] property to DynamicIcon class
  - Ensures consistent size handling between static and dynamic icons
  - Both now pass size as proper component props to Lucide React
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR fixes a critical bug in the Reflex icon system where dynamic icons (using state variables) were ignoring the size parameter. The issue occurred because the DynamicIcon class was missing the size: Var[int] property definition that exists in the base Icon class.

When using static icon names like rx.icon("home", size=16), the Icon.create() method returns an Icon instance with the proper size property. However, when using dynamic state variables like rx.icon(State.icon, size=16), the method returns a DynamicIcon instance (line 69 in the create method). Without the size property definition, the size parameter was being treated as a CSS style rather than a component prop, causing the underlying Lucide React component to ignore it and fall back to its default 24px size.

The fix adds the missing size: Var[int] property to the DynamicIcon class, ensuring both static and dynamic icons have identical property interfaces. This maintains consistent behavior regardless of whether the icon name is provided as a static string or dynamic state variable. The change integrates seamlessly with the existing component architecture, as both classes now share the same property definitions and follow the same rendering path through the Lucide React component system.

The PR also updates the corresponding .pyi hash file to reflect the type stub changes, which is standard practice for maintaining type safety in the codebase.

Confidence score: 5/5

  • This PR is extremely safe to merge with minimal risk of introducing any issues
  • Score reflects a simple, well-targeted bug fix that adds a missing property definition without changing any existing logic or behavior
  • No files require special attention as this is a straightforward one-line addition with clear intent and purpose

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

Comment thread pyi_hashes.json Outdated
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Aug 4, 2025

CodSpeed Performance Report

Merging #5665 will not alter performance

Comparing geekalaa:fix-dynamic-icon-size-5660-updated (3ef7458) with main (a1432bc)1

Summary

✅ 8 untouched benchmarks

Footnotes

  1. No successful run was found on main (b6c4905) during the generation of this report, so a1432bc was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@adhami3310
Copy link
Copy Markdown
Member

thanks for the fix :)

@adhami3310 adhami3310 merged commit 0809c11 into reflex-dev:main Aug 4, 2025
41 checks passed
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.

The rx.icon "size" attribute is parsed incorrectly in some statements

2 participants