question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Summary

We’ve been highjacking the itemToString function in the Dropdown to create an IconDropdown component for selecting warning icons. We simply returned an object from itemToString, and this worked well until 10.43/7.43 when the title attribute was added to the button in the Dropdown. However, now, visually it still works, but we get title="[Object object]" in the output of the selected icon. Would it be possible to add a prop to determine which function (itemToElement or itemToString) is used to render the selected item in the dropdown?

CodeSandbox example: https://codesandbox.io/s/goofy-water-2o4d4?file=/src/index.js

Screen Shot 2021-11-03 at 9 18 45 AM Screen Shot 2021-11-03 at 9 22 25 AM Screen Shot 2021-11-03 at 9 18 54 AM Screen Shot 2021-11-03 at 9 23 48 AM

Justification

No response

Desired UX and success metrics

No response

Required functionality

No response

Specific timeline issues / requests

No response

Available extra resources

I can write the PR.

Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
TannerScommented, Nov 20, 2021

Hi @josh, Will you all accept a PR for this? I’m happy to write it today if so. I think a renderSelectedItem callback that can render an element, but if it’s not provided we fallback to the current itemToString output makes the most sense.

The carbon team is always open for contributions

https://github.com/carbon-design-system/carbon/blob/main/.github/CONTRIBUTING.md

(not carbon team member)

1reaction
kevinsperrinecommented, Nov 3, 2021

@joshblack Sure thing: https://codesandbox.io/s/goofy-water-2o4d4?file=/src/index.js I added a bunch of comments to clarify.

Read more comments on GitHub >

github_iconTop Results From Across the Web

drop down list not updating selected item on subsequent calls
if I put a breakpoint on ddlyear.SelectedItem.Value.ToString(); the value actually never changes form the first call. it will change once, to ...
Read more >
How to get selected value in dropdown list using JavaScript
In this article, we will learn to get the selected values in the dropdown list in Javascript. We can get the values using...
Read more >
useSelect | Downshift
It returns a set of props that are meant to be called, and their results destructured on the dropdown's elements: its label, toggle...
Read more >
@unicef-polymer/etools-dropdown - npm
Polymer 3 dropdown element with searchable options, ... the id/optionValue of the selected item ... Selected value not found in options ...
Read more >
select and dropdown - Carbon Design System
The select component allows users to choose one option from a list. ... a list of options from which the users can select...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found