From 07656e7847afac6f5464442dbe955148c9491278 Mon Sep 17 00:00:00 2001 From: Josefina Mancilla Date: Wed, 7 Jul 2021 02:15:44 -0500 Subject: [PATCH 1/3] feat(ComboBox): add ability to forward ref --- packages/react/src/components/ComboBox/ComboBox-story.js | 3 +++ packages/react/src/components/ComboBox/ComboBox.js | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/react/src/components/ComboBox/ComboBox-story.js b/packages/react/src/components/ComboBox/ComboBox-story.js index e82284bf4662..80eece447b93 100644 --- a/packages/react/src/components/ComboBox/ComboBox-story.js +++ b/packages/react/src/components/ComboBox/ComboBox-story.js @@ -70,6 +70,9 @@ export const combobox = () => ( placeholder="Filter..." titleText="ComboBox title" helperText="Combobox helper text" + ref={() => { + console.log('some ref'); + }} /> ); diff --git a/packages/react/src/components/ComboBox/ComboBox.js b/packages/react/src/components/ComboBox/ComboBox.js index 30a4b6c283f2..f274d16cb222 100644 --- a/packages/react/src/components/ComboBox/ComboBox.js +++ b/packages/react/src/components/ComboBox/ComboBox.js @@ -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, @@ -308,7 +308,7 @@ const ComboBox = (props) => { aria-controls={inputProps['aria-controls']} {...inputProps} {...rest} - ref={mergeRefs(textInput, rootProps.ref)} + ref={mergeRefs(textInput, ref)} /> {invalid && ( { }} ); -}; +}); ComboBox.propTypes = { /** From baf8c13dd0f00438545ecab37c3bd8d1705ca72e Mon Sep 17 00:00:00 2001 From: Josefina Mancilla Date: Thu, 8 Jul 2021 00:13:25 -0500 Subject: [PATCH 2/3] chore: update combobox public api snapshot --- packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index a8589c4c7137..f95a0466ac95 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -438,6 +438,7 @@ Map { }, }, "ComboBox" => Object { + "$$typeof": Symbol(react.forward_ref), "defaultProps": Object { "ariaLabel": "Choose an item", "direction": "bottom", @@ -692,6 +693,7 @@ Map { "type": "node", }, }, + "render": [Function], }, "ComposedModal" => Object { "defaultProps": Object { From fa6e87d388014a707227e2b5742e4597dbd37025 Mon Sep 17 00:00:00 2001 From: Josefina Mancilla <32556167+jnm2377@users.noreply.github.com> Date: Thu, 8 Jul 2021 10:52:29 -0500 Subject: [PATCH 3/3] Update packages/react/src/components/ComboBox/ComboBox-story.js Co-authored-by: Josh Black --- packages/react/src/components/ComboBox/ComboBox-story.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/react/src/components/ComboBox/ComboBox-story.js b/packages/react/src/components/ComboBox/ComboBox-story.js index 80eece447b93..e82284bf4662 100644 --- a/packages/react/src/components/ComboBox/ComboBox-story.js +++ b/packages/react/src/components/ComboBox/ComboBox-story.js @@ -70,9 +70,6 @@ export const combobox = () => ( placeholder="Filter..." titleText="ComboBox title" helperText="Combobox helper text" - ref={() => { - console.log('some ref'); - }} /> );