-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(combobox): expose downshift actions through downshiftActions ref prop #17118
feat(combobox): expose downshift actions through downshiftActions ref prop #17118
Conversation
✅ Deploy Preview for carbon-elements ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for v11-carbon-react ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test story crashes when I interact with it
ReferenceError: component is not defined
at Object.onStateChange (https://deploy-preview-17118--v11-carbon-react.netlify.app/ComboBox-stories.5248b449.iframe.bundle.js:1:29192)
at callOnChangeProps (https://deploy-preview-17118--v11-carbon-react.netlify.app/1714.6bf0042b.iframe.bundle.js:1:31833)
at https://deploy-preview-17118--v11-carbon-react.netlify.app/1714.6bf0042b.iframe.bundle.js:1:33956
at Qj (https://deploy-preview-17118--v11-carbon-react.netlify.app/7319.005706cc.iframe.bundle.js:528:591606)
at Hk (https://deploy-preview-17118--v11-carbon-react.netlify.app/7319.005706cc.iframe.bundle.js:528:611538)
at Wk (https://deploy-preview-17118--v11-carbon-react.netlify.app/7319.005706cc.iframe.bundle.js:528:610306)
at Pk (https://deploy-preview-17118--v11-carbon-react.netlify.app/7319.005706cc.iframe.bundle.js:528:610376)
at Ek (https://deploy-preview-17118--v11-carbon-react.netlify.app/7319.005706cc.iframe.bundle.js:528:604186)
at jg (https://deploy-preview-17118--v11-carbon-react.netlify.app/7319.005706cc.iframe.bundle.js:528:545214)
at https://deploy-preview-17118--v11-carbon-react.netlify.app/7319.005706cc.iframe.bundle.js:528:601606
but changing component
to this
seems to fix the story and it looks like feature is working as expected
@emyarod ah my bad - I copied code from the stackblitz reproduction and forgot to update a couple of the usages from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! The stackblitz from this issue can console.log now
LGTM! 🚀
For posterity, here's the three approaches that I explored:
Option 1 patches the bug, avoids consumers having to store anything in state, and doesn't introduce problems for projects using the forwardRef. |
… prop (carbon-design-system#17118) * chore(wip): expose actions using downshiftActions ref prop * docs(combobox): add downshiftActions * fix(combobox): fix typings * chore: update snaps * fix: test story * fix(a11y): lock a11y checker to previous ruleset
Closes #17027
Follow up to #17089, this ensures that downshift action functions can be called from within parent components using Combobox.
Click to expand notes on compatibility
The functionality behind both
downshiftProps
anddownshiftActions
isn't guaranteed and is subject to change. This PR patches a functionality mismatch internal to downshift. It does not cover all previous action:If a consumer was using an action that is no longer available, such as
setState
, a functional equivalent can usually be found. This will require a code change in consuming projects.Changelog
New
downshiftActions
prop to ComboboxChanged
downshiftActions
anddownshiftProps
mergeRefs
usageTesting / Reviewing
The new test story in storybook implements the same logic referenced in the original issue report's stackblitz reproduction.
Go to the test story and validate base functionality. There should be no other changes to Combobox stories.