Conversation
Greptile SummaryThis PR updates several reflex-ui components —
Confidence Score: 4/5Safe to merge after fixing the four P1 bugs in input.py and button.py. Four P1 issues are present: a wrong Tailwind class in the lg size variant, silently dropped user custom_attrs, a Var-incompatible Python conditional for show_clear_button, and validation logic that throws on Var inputs for button variant/size. These produce incorrect visual output and runtime errors on valid usage patterns. packages/reflex-ui/src/reflex_ui/components/base/input.py and packages/reflex-ui/src/reflex_ui/components/base/button.py require fixes before merging.
|
| Filename | Overview |
|---|---|
| packages/reflex-ui/src/reflex_ui/components/base/button.py | Adds loading state, variant/size validation, and ClassNames namespace; validate_variant/validate_size will fail at runtime if a Var is passed for variant or size. |
| packages/reflex-ui/src/reflex_ui/components/base/input.py | Introduces HighLevelInput wrapper with icon, clear button, and size variants; has three bugs: rounded-lg inconsistency for lg size, user custom_attrs silently dropped, and show_clear_button Var not handled correctly. |
| packages/reflex-ui/src/reflex_ui/components/base/tabs.py | Adds size-aware tabs components (Root, List, Tab, Indicator, Panel) with ClassNames; list and indicator sizes share identical class strings across sm/md/lg which may be intentional. |
| packages/reflex-ui/src/reflex_ui/components/base/textarea.py | Simple textarea wrapper with auto-attribute defaults and design-token class names; no issues found. |
| packages/reflex-ui-shared/src/reflex_ui_shared/styles/globals.css | CSS design-token file defining color palette, shadow, font, and radius variables; no logic issues identified. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["HighLevelInput.create()"] --> B["Extract _el_input_props from props"]
B --> C["Pop icon, size, id, class_name,\nshow_clear_button, clear_events"]
C --> D["Build input_props with id +\ncustom_attrs (DEFAULT_INPUT_ATTRS only)"]
D --> E["Div.create()"]
E --> F{icon?}
F -->|yes| G["Span + hi(icon)"]
F -->|no| H["(None)"]
G --> I["InputRoot.create(**input_props)"]
H --> I
I --> J{show_clear_button?\nPython truthiness only}
J -->|bool True| K["_create_clear_button(id, clear_events)"]
J -->|bool False| L["(None)"]
J -->|Var - always True| K
K --> M["Button with set_value + set_focus"]
Comments Outside Diff (4)
-
packages/reflex-ui/src/reflex_ui/components/base/input.py, line 23 (link)Inconsistent border-radius class for
lgsizeThe
lgsize usesrounded-lg(a standard Tailwind class) while every other size —xs,sm,md, andxl— uses the project's customrounded-ui-*scale. This will produce a visually different corner radius forlginputs, breaking the design-token system. -
packages/reflex-ui/src/reflex_ui/components/base/input.py, line 147-151 (link)User-provided
custom_attrssilently droppedcustom_attrsis not in_el_input_props, so it is never moved intoinput_propsby the dict-comprehension on line 135.input_props.get("custom_attrs", {})therefore always returns{}, and anycustom_attrskwarg the caller passes is left inprops, applied to the outerDivinstead of theInputRoot. The intent is clearly to merge caller-supplied HTML attributes into the input element, but the current code silently discards them.To fix this, extract
custom_attrsfrompropsbefore (or alongside) the_el_input_propsfiltering:custom_attrs_override = props.pop("custom_attrs", {}) input_props.update({ "id": id, "custom_attrs": { **DEFAULT_INPUT_ATTRS, **custom_attrs_override, }, })
-
packages/reflex-ui/src/reflex_ui/components/base/input.py, line 163 (link)show_clear_buttonas aVaris always truthyshow_clear_buttonis typed asVar[bool], but the Python-level conditionalif show_clear_buttonevaluates the truthiness of theVarobject itself, which is alwaysTrue. Passingshow_clear_button=rx.State.hide_clear(aVar) will always render the clear button regardless of the state value. If dynamic hiding is not a supported use-case, update the type annotation tobool; if it should be supported, usecond()to conditionally render the button at the React level. -
packages/reflex-ui/src/reflex_ui/components/base/button.py, line 90-91 (link)validate_variantfails whenvariantis aVarThe class declares
variant: Var[LiteralButtonVariant], which implies callers can pass a reactiveVar. However,validate_variantchecksif variant not in BUTTON_VARIANTS["variant"]— aVarobject will never be a key in that dict, so validation raisesValueErrorfor any dynamic variant. Similarly, line 99 doesBUTTON_VARIANTS['variant'][variant], which would raiseKeyError. Either restrict the type annotation toLiteralButtonVariant(plain string only) or guard the validation path withif not isinstance(variant, Var).
Reviews (1): Last reviewed commit: "Update some reflex ui components" | Re-trigger Greptile
No description provided.