Skip to content

Commit

Permalink
fix: Allow ComboBox to accept the FocusableRef for ref (#2121)
Browse files Browse the repository at this point in the history
- Wasn't allowing a ref to be passed in to ComboBox
  • Loading branch information
mofojed authored Jul 3, 2024
1 parent 115e057 commit 8fe9bad
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions packages/components/src/spectrum/comboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import {
ComboBox as SpectrumComboBox,
SpectrumComboBoxProps,
Expand All @@ -9,24 +10,19 @@ import { PickerPropsT, usePickerProps } from '../picker';

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

export function ComboBox({
UNSAFE_className,
...props
}: ComboBoxProps): JSX.Element {
const {
defaultSelectedKey,
disabledKeys,
ref,
selectedKey,
...comboBoxProps
} = usePickerProps(props);
export const ComboBox = React.forwardRef(function ComboBox(
{ UNSAFE_className, ...props }: ComboBoxProps,
ref: FocusableRef<HTMLElement>
): JSX.Element {
const { defaultSelectedKey, disabledKeys, selectedKey, ...comboBoxProps } =
usePickerProps(props);

return (
<SpectrumComboBox
// eslint-disable-next-line react/jsx-props-no-spreading
{...comboBoxProps}
UNSAFE_className={cl('dh-combobox', UNSAFE_className)}
ref={ref as FocusableRef<HTMLElement>}
ref={ref}
// Type assertions are necessary here since Spectrum types don't account
// for number and boolean key values even though they are valid runtime
// values.
Expand All @@ -41,4 +37,4 @@ export function ComboBox({
}
/>
);
}
});

0 comments on commit 8fe9bad

Please sign in to comment.