11import * as React from 'react'
2- import { type ComponentProps , forwardRef } from 'react'
2+ import { forwardRef } from 'react'
33
44import { Box } from '../box'
55
@@ -9,12 +9,15 @@ import type { ObfuscatedClassName } from '../utils/common-types'
99
1010export type FieldChromeContainerProps = {
1111 /**
12- * The control element to wrap. The wrapper chrome (border, hover/focus,
13- * disabled/read-only background tint, error border) derives from
14- * attributes on this descendant.
12+ * The control element (or a layout containing one) to wrap. The wrapper
13+ * chrome (border, hover/focus, disabled/read-only background tint, error
14+ * border) derives from attributes on the focusable descendant. Clicking
15+ * the wrapper focuses the first focusable input/select/textarea
16+ * descendant and dispatches a `.click()` (or `.showPicker()` for native
17+ * `<select>`).
1518 *
16- * Clicking the wrapper focuses the first focusable descendant and
17- * dispatches a `.click()` (or `.showPicker()` for native `<select>`) .
19+ * Contract: assumes a single focusable control descendant. Behavior is
20+ * undefined if multiple focusable controls are inside .
1821 */
1922 children : React . ReactNode
2023
@@ -24,8 +27,16 @@ export type FieldChromeContainerProps = {
2427 * - `large` — used by `BorderedTextField`'s outlined chrome.
2528 */
2629 borderRadius ?: 'small' | 'large'
27- } & ObfuscatedClassName &
28- Omit < ComponentProps < typeof Box > , 'className' >
30+
31+ /**
32+ * Optional click handler. Fires before the click-to-focus dispatch.
33+ * Intended for composition with library wrappers (e.g. Ariakit's
34+ * render-prop pattern) that forward an upstream onClick to the chrome
35+ * element. Component-level click handling normally lives on the inner
36+ * control.
37+ */
38+ onClick ?: React . MouseEventHandler < HTMLDivElement >
39+ } & ObfuscatedClassName
2940
3041/**
3142 * Private primitive shared by `ControlPresentation` and `BorderedTextField`.
@@ -40,16 +51,12 @@ export type FieldChromeContainerProps = {
4051 */
4152export const FieldChromeContainer = forwardRef < HTMLDivElement , FieldChromeContainerProps > (
4253 function FieldChromeContainer (
43- { borderRadius = 'small' , exceptionallySetClassName, children , ... rest } ,
54+ { borderRadius = 'small' , exceptionallySetClassName, onClick , children } ,
4455 ref ,
4556 ) {
4657 const controlWrapperRef = React . useRef < HTMLDivElement > ( null )
4758 const isDispatchedReentryRef = React . useRef ( false )
4859
49- const { onClick, ...restWithoutClick } = rest as typeof rest & {
50- onClick ?: React . MouseEventHandler < HTMLDivElement >
51- }
52-
5360 function handleWrapperClick ( event : React . MouseEvent < HTMLDivElement > ) {
5461 if ( isDispatchedReentryRef . current ) {
5562 isDispatchedReentryRef . current = false
@@ -86,7 +93,6 @@ export const FieldChromeContainer = forwardRef<HTMLDivElement, FieldChromeContai
8693 return (
8794 < Box
8895 ref = { ref }
89- { ...restWithoutClick }
9096 className = { [
9197 styles . container ,
9298 borderRadius === 'large' ? styles . borderRadiusLarge : styles . borderRadiusSmall ,
0 commit comments