fix: segmented_control indicator renders for >10 items#6344
fix: segmented_control indicator renders for >10 items#6344FarhanAliRaza wants to merge 2 commits intoreflex-dev:mainfrom
Conversation
Radix Themes 3.3.0 ships hardcoded nth-child rules for the sliding indicator up to 10 items only (radix-ui/themes#730); beyond that the indicator collapses. Expose item count and selected index as CSS custom properties on the root and override width/transform with one calc()-driven rule, supporting any number of items.
39089fd to
412240a
Compare
Greptile SummaryThis PR fixes two independent issues: (1) the Radix Themes
Confidence Score: 4/5Safe to merge after removing the accidental empty file One P1 issue (accidental empty file) must be cleaned up; remaining findings are P2 style/documentation concerns that do not block correctness. The empty Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["SegmentedControlRoot.create()"] --> B{type == 'multiple'?}
B -->|Yes| Z["super().create() — Radix default rules apply"]
B -->|No| C["_collect_item_values(children)"]
C --> D{single Foreach?}
D -->|Yes| E{iterable is ArrayVar AND\nrender_fn returns SegmentedControlItem?}
E -->|No| Z
E -->|Yes| G["iterable.foreach(el => render_fn(el).value)"]
D -->|No| F{all children are\nSegmentedControlItem with value?}
F -->|No| Z
F -->|Yes| H["LiteralArrayVar.create(values)"]
G --> I["values_var: ArrayVar"]
H --> I
I --> J{selected prop present?}
J -->|No| Z
J -->|Yes| K["inject --rx-sc-count and --rx-sc-idx\ninto style props"]
K --> L["super().create()"]
L --> M["add_style(): override\n.rt-SegmentedControlIndicator\nwidth + transform via calc()"]
|
|
i'm not sure we want to fix this here, ideally this should be fixed upstream |
All Submissions:
Radix Themes 3.3.0 ships hardcoded nth-child rules for the sliding
indicator up to 10 items only (radix-ui/themes#730); beyond that the
indicator collapses. Expose item count and selected index as CSS
custom properties on the root and override width/transform with one
calc()-driven rule, supporting any number of items.
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features:
closes #5651