Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.

Commit 2d9739e

Browse files
authored
Fix adding select empty values for docs component (#1796)
* Fxi select empty values * bump * remove that pip install * update tests * revert those * revert those * bump * bump
1 parent b004edb commit 2d9739e

2 files changed

Lines changed: 124 additions & 120 deletions

File tree

‎pcweb/pages/docs/component.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
124124
for arg in type_.__args__
125125
if get_origin(arg) is Literal
126126
for lit_arg in arg.__args__
127+
if str(lit_arg) != ""
127128
]
128129
option = literal_values[0]
129130
name = get_id(f"{component.__qualname__}_{prop.name}")
@@ -144,8 +145,9 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
144145
value=var,
145146
on_change=setter,
146147
)
147-
# Get the first option.
148-
option = type_.__args__[0]
148+
# Get the first non-empty option.
149+
non_empty_args = [a for a in type_.__args__ if str(a) != ""]
150+
option = non_empty_args[0] if non_empty_args else type_.__args__[0]
149151
name = get_id(f"{component.__qualname__}_{prop.name}")
150152
PropDocsState.add_var(name, str, option)
151153
var = getattr(PropDocsState, name)
@@ -186,6 +188,7 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
186188
class_name="relative shrink-0 rounded-md size-8 cursor-pointer",
187189
)
188190
for color in list(map(str, type_.__args__))
191+
if color != ""
189192
],
190193
columns="6",
191194
spacing="3",
@@ -208,6 +211,7 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
208211
),
209212
)
210213
for item in list(map(str, type_.__args__))
214+
if item != ""
211215
]
212216
),
213217
),

0 commit comments

Comments
 (0)