Skip to content

Commit 8b6a903

Browse files
committed
[TF-388] Fix Safari rendering selects shorter than other form fields
Safari's native select control ignores vertical padding and renders at a fixed intrinsic height, so dropdowns appeared shorter than the adjacent text/number inputs (Chrome honored the padding, hiding the mismatch). Set appearance-none on the shared Select so it uses the standard box model and respects py-2 across browsers, and render a custom ChevronDown indicator in place of the removed native arrow. Same fix as rallyup cc7c9ee.
1 parent bdf2007 commit 8b6a903

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

web/src/components/ui/Select.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { forwardRef } from 'react'
22
import type { SelectHTMLAttributes } from 'react'
3+
import { ChevronDown } from 'lucide-react'
34

45
interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
56
label?: string
@@ -16,16 +17,25 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
1617
{label}
1718
</label>
1819
)}
19-
<select
20-
ref={ref}
21-
id={selectId}
22-
className={`block w-full rounded-md border px-3 py-2 text-sm shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 dark:bg-gray-800 dark:border-gray-600 dark:text-gray-100 disabled:opacity-50 disabled:cursor-not-allowed ${
23-
error ? 'border-red-300' : 'border-gray-300 dark:border-gray-600'
24-
} ${className}`}
25-
{...props}
26-
>
27-
{children}
28-
</select>
20+
<div className="relative">
21+
<select
22+
ref={ref}
23+
id={selectId}
24+
// appearance-none keeps the box model consistent across browsers — Safari's
25+
// native select control ignores vertical padding and renders shorter than
26+
// text inputs. We render our own chevron below in its place.
27+
className={`block w-full appearance-none rounded-md border px-3 py-2 pr-10 text-sm shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 dark:bg-gray-800 dark:border-gray-600 dark:text-gray-100 disabled:opacity-50 disabled:cursor-not-allowed ${
28+
error ? 'border-red-300' : 'border-gray-300 dark:border-gray-600'
29+
} ${className}`}
30+
{...props}
31+
>
32+
{children}
33+
</select>
34+
<ChevronDown
35+
className="pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500"
36+
aria-hidden="true"
37+
/>
38+
</div>
2939
{error && <p className="mt-1 text-sm text-red-600">{error}</p>}
3040
</div>
3141
)

0 commit comments

Comments
 (0)