Skip to content

Commit 8fe9bad

Browse files
authored
fix: Allow ComboBox to accept the FocusableRef for ref (#2121)
- Wasn't allowing a ref to be passed in to ComboBox
1 parent 115e057 commit 8fe9bad

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
import {
23
ComboBox as SpectrumComboBox,
34
SpectrumComboBoxProps,
@@ -9,24 +10,19 @@ import { PickerPropsT, usePickerProps } from '../picker';
910

1011
export type ComboBoxProps = PickerPropsT<SpectrumComboBoxProps<NormalizedItem>>;
1112

12-
export function ComboBox({
13-
UNSAFE_className,
14-
...props
15-
}: ComboBoxProps): JSX.Element {
16-
const {
17-
defaultSelectedKey,
18-
disabledKeys,
19-
ref,
20-
selectedKey,
21-
...comboBoxProps
22-
} = usePickerProps(props);
13+
export const ComboBox = React.forwardRef(function ComboBox(
14+
{ UNSAFE_className, ...props }: ComboBoxProps,
15+
ref: FocusableRef<HTMLElement>
16+
): JSX.Element {
17+
const { defaultSelectedKey, disabledKeys, selectedKey, ...comboBoxProps } =
18+
usePickerProps(props);
2319

2420
return (
2521
<SpectrumComboBox
2622
// eslint-disable-next-line react/jsx-props-no-spreading
2723
{...comboBoxProps}
2824
UNSAFE_className={cl('dh-combobox', UNSAFE_className)}
29-
ref={ref as FocusableRef<HTMLElement>}
25+
ref={ref}
3026
// Type assertions are necessary here since Spectrum types don't account
3127
// for number and boolean key values even though they are valid runtime
3228
// values.
@@ -41,4 +37,4 @@ export function ComboBox({
4137
}
4238
/>
4339
);
44-
}
40+
});

0 commit comments

Comments
 (0)