Skip to content

Commit

Permalink
feat(ComboBox): add ability to forward ref (#9136)
Browse files Browse the repository at this point in the history
* feat(ComboBox): add ability to forward ref

* chore: update combobox public api snapshot

* Update packages/react/src/components/ComboBox/ComboBox-story.js

Co-authored-by: Josh Black <[email protected]>

Co-authored-by: Josh Black <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 8, 2021
1 parent 0f73241 commit b68f837
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ Map {
},
},
"ComboBox" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"ariaLabel": "Choose an item",
"direction": "bottom",
Expand Down Expand Up @@ -692,6 +693,7 @@ Map {
"type": "node",
},
},
"render": [Function],
},
"ComposedModal" => Object {
"defaultProps": Object {
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/components/ComboBox/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const findHighlightedIndex = ({ items, itemToString }, inputValue) => {

const getInstanceId = setupGetInstanceId();

const ComboBox = (props) => {
const ComboBox = React.forwardRef((props, ref) => {
const {
ariaLabel,
className: containerClassName,
Expand Down Expand Up @@ -308,7 +308,7 @@ const ComboBox = (props) => {
aria-controls={inputProps['aria-controls']}
{...inputProps}
{...rest}
ref={mergeRefs(textInput, rootProps.ref)}
ref={mergeRefs(textInput, ref)}
/>
{invalid && (
<WarningFilled16
Expand Down Expand Up @@ -387,7 +387,7 @@ const ComboBox = (props) => {
}}
</Downshift>
);
};
});

ComboBox.propTypes = {
/**
Expand Down

0 comments on commit b68f837

Please sign in to comment.