Compare commits

...

3 Commits

Author SHA1 Message Date
Nicholas Tindle
f66e985c0f Merge branch 'dev' into otto/secrt-2157-fix-select-empty-string 2026-04-03 11:49:38 +02:00
Zamil Majdy
a79c265925 fix(frontend): preserve falsy values in SelectWidget and filter empty-string options at top level
- Replace `value || undefined` with explicit null/empty-string check to preserve
  falsy values like 0 (used as selectedIndex in OneOfField)
- Move empty-string option filter to top of component so both single-select and
  multi-select paths benefit from it
- Remove redundant filter in Select options prop
2026-03-31 12:35:18 +02:00
Otto
8ab5d7bd20 fix(frontend): prevent Select.Item crash on empty-string enum values
Radix UI's Select.Item throws when value="". The SelectWidget used
value={value ?? ""} which passes empty string for null/undefined form
values, and passed enum options through without filtering.

- Use value || undefined to show placeholder for unset values
- Filter out empty-string options before rendering SelectItems

Resolves SECRT-2157
2026-03-20 09:16:09 +00:00

View File

@@ -24,7 +24,9 @@ export const SelectWidget = (props: WidgetProps) => {
id,
formContext,
} = props;
const enumOptions = options.enumOptions || [];
const enumOptions = (options.enumOptions || []).filter(
(option: any) => option.value !== "",
);
const type = mapJsonSchemaTypeToInputType(props.schema);
const { size = "small" } = formContext || {};
@@ -61,7 +63,7 @@ export const SelectWidget = (props: WidgetProps) => {
hideLabel={true}
disabled={disabled || readonly}
size={selectSize as any}
value={value ?? ""}
value={value === "" || value == null ? undefined : value}
onValueChange={onChange}
options={
enumOptions?.map((option: any) => ({