@@ -770,22 +770,20 @@ function ComboboxFn<TValue, TTag extends ElementType = typeof DEFAULT_COMBOBOX_T
770
770
data . comboboxState === ComboboxState . Open
771
771
)
772
772
773
- let slot = useMemo (
774
- ( ) =>
775
- ( {
776
- open : data . comboboxState === ComboboxState . Open ,
777
- disabled,
778
- activeIndex : data . activeOptionIndex ,
779
- activeOption :
780
- data . activeOptionIndex === null
781
- ? null
782
- : data . virtual
783
- ? data . virtual . options [ data . activeOptionIndex ?? 0 ]
784
- : ( data . options [ data . activeOptionIndex ] ?. dataRef . current . value as TValue ) ?? null ,
785
- value,
786
- } ) satisfies ComboboxRenderPropArg < unknown > ,
787
- [ data , disabled , value ]
788
- )
773
+ let slot = useMemo ( ( ) => {
774
+ return {
775
+ open : data . comboboxState === ComboboxState . Open ,
776
+ disabled,
777
+ activeIndex : data . activeOptionIndex ,
778
+ activeOption :
779
+ data . activeOptionIndex === null
780
+ ? null
781
+ : data . virtual
782
+ ? data . virtual . options [ data . activeOptionIndex ?? 0 ]
783
+ : ( data . options [ data . activeOptionIndex ] ?. dataRef . current . value as TValue ) ?? null ,
784
+ value,
785
+ } satisfies ComboboxRenderPropArg < unknown >
786
+ } , [ data , disabled , value ] )
789
787
790
788
let selectActiveOption = useEvent ( ( ) => {
791
789
if ( data . activeOptionIndex === null ) return
@@ -958,6 +956,7 @@ export type ComboboxInputProps<
958
956
InputPropsWeControl ,
959
957
{
960
958
defaultValue ?: TType
959
+ disabled ?: boolean
961
960
displayValue ?( item : TType ) : string
962
961
onChange ?( event : React . ChangeEvent < HTMLInputElement > ) : void
963
962
autoFocus ?: boolean
@@ -970,18 +969,21 @@ function InputFn<
970
969
// But today is not that day..
971
970
TType = Parameters < typeof ComboboxRoot > [ 0 ] [ 'value' ] ,
972
971
> ( props : ComboboxInputProps < TTag , TType > , ref : Ref < HTMLInputElement > ) {
972
+ let data = useData ( 'Combobox.Input' )
973
+ let actions = useActions ( 'Combobox.Input' )
974
+
973
975
let internalId = useId ( )
974
976
let providedId = useProvidedId ( )
975
977
let {
976
978
id = providedId || `headlessui-combobox-input-${ internalId } ` ,
977
979
onChange,
978
980
displayValue,
981
+ disabled = data . disabled || false ,
982
+ autoFocus = false ,
979
983
// @ts -ignore: We know this MAY NOT exist for a given tag but we only care when it _does_ exist.
980
984
type = 'text' ,
981
985
...theirProps
982
986
} = props
983
- let data = useData ( 'Combobox.Input' )
984
- let actions = useActions ( 'Combobox.Input' )
985
987
986
988
let inputRef = useSyncRefs ( data . inputRef , ref , useFloatingReference ( ) )
987
989
let ownerDocument = useOwnerDocument ( data . inputRef )
@@ -1320,20 +1322,18 @@ function InputFn<
1320
1322
let labelledBy = useLabelledBy ( )
1321
1323
let describedBy = useDescribedBy ( )
1322
1324
1323
- let { isFocused : focus , focusProps } = useFocusRing ( { autoFocus : props . autoFocus ?? false } )
1324
- let { isHovered : hover , hoverProps } = useHover ( { isDisabled : data . disabled ?? false } )
1325
+ let { isFocused : focus , focusProps } = useFocusRing ( { autoFocus } )
1326
+ let { isHovered : hover , hoverProps } = useHover ( { isDisabled : disabled } )
1325
1327
1326
- let slot = useMemo (
1327
- ( ) =>
1328
- ( {
1329
- open : data . comboboxState === ComboboxState . Open ,
1330
- disabled : data . disabled ,
1331
- hover,
1332
- focus,
1333
- autofocus : props . autoFocus ?? false ,
1334
- } ) satisfies InputRenderPropArg ,
1335
- [ data , hover , focus , props . autoFocus ]
1336
- )
1328
+ let slot = useMemo ( ( ) => {
1329
+ return {
1330
+ open : data . comboboxState === ComboboxState . Open ,
1331
+ disabled,
1332
+ hover,
1333
+ focus,
1334
+ autofocus : autoFocus ,
1335
+ } satisfies InputRenderPropArg
1336
+ } , [ data , hover , focus , autoFocus , disabled ] )
1337
1337
1338
1338
let ourProps = mergeProps (
1339
1339
{
@@ -1365,7 +1365,8 @@ function InputFn<
1365
1365
? displayValue ?.( data . defaultValue as unknown as TType )
1366
1366
: null ) ??
1367
1367
data . defaultValue ,
1368
- disabled : data . disabled ,
1368
+ disabled : disabled || undefined ,
1369
+ autoFocus,
1369
1370
onCompositionStart : handleCompositionStart ,
1370
1371
onCompositionEnd : handleCompositionEnd ,
1371
1372
onKeyDown : handleKeyDown ,
@@ -1411,6 +1412,7 @@ export type ComboboxButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON
1411
1412
ButtonPropsWeControl ,
1412
1413
{
1413
1414
autoFocus ?: boolean
1415
+ disabled ?: boolean
1414
1416
}
1415
1417
>
1416
1418
@@ -1422,7 +1424,12 @@ function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(
1422
1424
let actions = useActions ( 'Combobox.Button' )
1423
1425
let buttonRef = useSyncRefs ( data . buttonRef , ref )
1424
1426
let internalId = useId ( )
1425
- let { id = `headlessui-combobox-button-${ internalId } ` , ...theirProps } = props
1427
+ let {
1428
+ id = `headlessui-combobox-button-${ internalId } ` ,
1429
+ disabled = data . disabled || false ,
1430
+ autoFocus = false ,
1431
+ ...theirProps
1432
+ } = props
1426
1433
let d = useDisposables ( )
1427
1434
1428
1435
let handleKeyDown = useEvent ( ( event : ReactKeyboardEvent < HTMLUListElement > ) => {
@@ -1479,22 +1486,20 @@ function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(
1479
1486
1480
1487
let labelledBy = useLabelledBy ( [ id ] )
1481
1488
1482
- let { isFocusVisible : focus , focusProps } = useFocusRing ( { autoFocus : props . autoFocus ?? false } )
1483
- let { isHovered : hover , hoverProps } = useHover ( { isDisabled : data . disabled ?? false } )
1484
- let { pressed : active , pressProps } = useActivePress ( { disabled : data . disabled ?? false } )
1489
+ let { isFocusVisible : focus , focusProps } = useFocusRing ( { autoFocus } )
1490
+ let { isHovered : hover , hoverProps } = useHover ( { isDisabled : disabled } )
1491
+ let { pressed : active , pressProps } = useActivePress ( { disabled } )
1485
1492
1486
- let slot = useMemo (
1487
- ( ) =>
1488
- ( {
1489
- open : data . comboboxState === ComboboxState . Open ,
1490
- active : active || data . comboboxState === ComboboxState . Open ,
1491
- disabled : data . disabled ,
1492
- value : data . value ,
1493
- hover,
1494
- focus,
1495
- } ) satisfies ButtonRenderPropArg ,
1496
- [ data , hover , focus , active ]
1497
- )
1493
+ let slot = useMemo ( ( ) => {
1494
+ return {
1495
+ open : data . comboboxState === ComboboxState . Open ,
1496
+ active : active || data . comboboxState === ComboboxState . Open ,
1497
+ disabled,
1498
+ value : data . value ,
1499
+ hover,
1500
+ focus,
1501
+ } satisfies ButtonRenderPropArg
1502
+ } , [ data , hover , focus , active , disabled ] )
1498
1503
let ourProps = mergeProps (
1499
1504
{
1500
1505
ref : buttonRef ,
@@ -1505,7 +1510,8 @@ function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(
1505
1510
'aria-controls' : data . optionsRef . current ?. id ,
1506
1511
'aria-expanded' : data . comboboxState === ComboboxState . Open ,
1507
1512
'aria-labelledby' : labelledBy ,
1508
- disabled : data . disabled ,
1513
+ disabled : disabled || undefined ,
1514
+ autoFocus,
1509
1515
onClick : handleClick ,
1510
1516
onKeyDown : handleKeyDown ,
1511
1517
} ,
@@ -1592,14 +1598,12 @@ function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(
1592
1598
1593
1599
let labelledBy = useLabelledBy ( [ data . buttonRef . current ?. id ] )
1594
1600
1595
- let slot = useMemo (
1596
- ( ) =>
1597
- ( {
1598
- open : data . comboboxState === ComboboxState . Open ,
1599
- option : undefined ,
1600
- } ) satisfies OptionsRenderPropArg ,
1601
- [ data ]
1602
- )
1601
+ let slot = useMemo ( ( ) => {
1602
+ return {
1603
+ open : data . comboboxState === ComboboxState . Open ,
1604
+ option : undefined ,
1605
+ } satisfies OptionsRenderPropArg
1606
+ } , [ data ] )
1603
1607
let ourProps = mergeProps ( anchor ? getFloatingPanelProps ( ) : { } , {
1604
1608
'aria-labelledby' : labelledBy ,
1605
1609
role : 'listbox' ,
0 commit comments