Skip to content
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(dropdown): add renderSelectedItem prop #10188

Conversation

kevinsperrine
Copy link
Contributor

@kevinsperrine kevinsperrine commented Nov 29, 2021

Closes #10038

Adds a renderSelectedItem prop as a callback when it would be helpful to render the currently selected item as an element instead of just text

Changelog

New

  • renderSelectedItem prop that is called to render the current selectedItem as an element
  • added unit tests
  • added RenderSelectedItem demo story

Changed

  • if given, renderSelectedItem will be called and passed the currently selected item allowing the consumer to render the item as desired
  • updated public api snapshot

Testing / Reviewing

  • Added a RenderSelectedItem story to demonstrate the functionality
  • added new tests to confirm

@kevinsperrine kevinsperrine requested review from a team as code owners November 29, 2021 16:07
@netlify
Copy link

netlify bot commented Nov 29, 2021

✔️ Deploy Preview for carbon-react-next ready!

🔨 Explore the source changes: facc191

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-react-next/deploys/61af9aad4139e1000780b0bd

😎 Browse the preview: https://deploy-preview-10188--carbon-react-next.netlify.app

@netlify
Copy link

netlify bot commented Nov 29, 2021

✔️ Deploy Preview for carbon-elements ready!

🔨 Explore the source changes: facc191

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/61af9aad98d7200007f3e2a7

😎 Browse the preview: https://deploy-preview-10188--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Nov 29, 2021

✔️ Deploy Preview for carbon-components-react ready!
Built without sensitive environment variables

🔨 Explore the source changes: facc191

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/61af9aadffe84500074f6068

😎 Browse the preview: https://deploy-preview-10188--carbon-components-react.netlify.app

Copy link
Contributor

@dakahn dakahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there! Code lgtm, but do you think we could demonstrate this props intended usage in the story you've built out. Might help with reviews as well 👍🏾

@kevinsperrine
Copy link
Contributor Author

Hey there! Code lgtm, but do you think we could demonstrate this props intended usage in the story you've built out. Might help with reviews as well 👍🏾

Yep! @dakahn, I just pushed up a version that uses icons in both the itemToElement callback for when the dropdown is open and the renderSelectedItem for when an item has been chosen.

@kevinsperrine kevinsperrine requested a review from dakahn December 6, 2021 14:05
Copy link
Contributor

@dakahn dakahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! The story is a big help thanks. Tested and speaks as expected with both NVDA and JAWS 2021 on Windows 11 🏄🏾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dropdown]: option to call itemToElement for selectedItem not just list of items
3 participants