Skip to content

Commit 98e3170

Browse files
fix(select): make renderValue and placeholder work together (#413)
1 parent da6eee1 commit 98e3170

File tree

11 files changed

+1604
-58
lines changed

11 files changed

+1604
-58
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
"@cloudflare/kumo": patch
3+
---
4+
5+
fix(Select): TypeScript inference with `strictNullChecks` and `renderValue`/`placeholder` interaction
6+
7+
**TypeScript fix:** Under `strictNullChecks`, using `value={objectOrNull}` would cause `T` to be inferred as `never`, making callbacks like `onValueChange` and `renderValue` unusable. This is now fixed.
8+
9+
**Runtime fix:** `renderValue` is now only called with non-null values. When value is null, the `placeholder` is shown instead. Previously, `renderValue` would receive `null` at runtime despite being typed as `(value: T) => ReactNode`.
10+
11+
```tsx
12+
// Recommended pattern
13+
<Select
14+
placeholder="Select..."
15+
value={value}
16+
onValueChange={setValue} // value is T | null (works with strictNullChecks)
17+
renderValue={(v) => v.name} // v is T (non-null), no defensive coding needed
18+
/>
19+
```

.opencode/package-lock.json

Lines changed: 271 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)